Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement File Provider file synchronisation engine for macOS #5527

Merged
merged 332 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
332 commits
Select commit Hold shift + click to select a range
67de829
Keep track of requested enumerators when account is being configured,…
claucambra Jan 27, 2023
325878b
Improve logging in FileProviderEnumerator
claucambra Jan 27, 2023
2f5d0e6
Set up NextcloudKit account in FileProviderExtension
claucambra Jan 28, 2023
38d1b95
Fix the webDavUrl for NextcloudAccount
claucambra Jan 30, 2023
7cb4939
Fix NextcloudItemMetadataTable status query type
claucambra Jan 30, 2023
ceb9aa3
Fix try/catch indentation in NextcloudFileDatabaseManager
claucambra Jan 30, 2023
ff25f94
Fix URL path composition for utility methods in NextcloudFileProvider…
claucambra Jan 30, 2023
06f2714
Improve and fix enumerator signalling after initial account setup in …
claucambra Jan 30, 2023
5c01109
Switch to develop branch of NextcloudKit
claucambra Jan 30, 2023
b154740
Add ability for FileProviderDomainManager to wipe domains
claucambra Feb 1, 2023
74222da
Don't unnecessarily fail to provide parentItemIdentifier in Nextcloud…
claucambra Feb 1, 2023
9c18d36
Add convenience method to check if any file metadatas have been store…
claucambra Feb 1, 2023
c458018
Only reimport entire file provider domain if there have been no recor…
claucambra Feb 1, 2023
476d6a2
Don't unnecessarily fail to get serverUrl for enumerated item in File…
claucambra Feb 1, 2023
3be08bb
Fix scanning of child directories in FileProviderEnumerator
claucambra Feb 1, 2023
2f12d9b
Remove setting connection status from fileproviderdomainmanager, this…
claucambra Feb 2, 2023
6a258c0
Properly handle errors when trying to read server url in FileProvider…
claucambra Feb 2, 2023
98afd95
Fix Realm crashes when trying to delete certain objects
claucambra Feb 2, 2023
f0524d4
Switch to NCKit work/unsharedify-nckit branch
claucambra Feb 2, 2023
230b55d
Stop using NextcloudKit.shared and NKCommon.shared, use specific Next…
claucambra Feb 2, 2023
3342fb7
Add convenience properties to NextcloudItemMetadataTable
claucambra Feb 14, 2023
90d5c8f
Add convenience method to update item metadata status
claucambra Feb 14, 2023
2935125
Add convenience method to add item metadata status
claucambra Feb 16, 2023
b70e9d1
Add convenience method to add local file metadata from item metadata …
claucambra Feb 16, 2023
91ad815
Add working file content fetching
claucambra Feb 16, 2023
dc2e14d
Add convenience method to add directory metadata to database
claucambra Feb 20, 2023
81dd596
Unprivate direcotryMetadataFromItemMetadata in database manager
claucambra Feb 20, 2023
7d2c21c
Don't unnecessarily fetch item metadata when fetching contents
claucambra Feb 20, 2023
992ef7b
Add ability for extension to create items correctly on the server
claucambra Feb 21, 2023
c6cc87a
Extension can now upload modifications to items on the server
claucambra Feb 27, 2023
47d98a4
Add methods to delete metadata types in NextcloudFilesDatabaseManager
claucambra Feb 27, 2023
c3f79ee
Add methods to rename directory metadata and propagate modifications …
claucambra Feb 27, 2023
5f24527
Properly handle renaming folders in FileProviderExtension modifyItem
claucambra Feb 27, 2023
c7660b5
Add convenience method to rename file item metadatas in database
claucambra Mar 6, 2023
0f2fbf7
Handle renaming of both files and folders correctly in FileProviderEx…
claucambra Mar 6, 2023
020c5d5
Only try upload of modified item in FileProviderExtension if that had…
claucambra Mar 6, 2023
a146b65
Properly handle several modify item fields at once in FileProviderExt…
claucambra Mar 6, 2023
3e0a9e9
Support reparenting file provider items correctly
claucambra Mar 6, 2023
06b59b6
Correctly fulfill delete item requests on server
claucambra Mar 7, 2023
54587e8
Clarify current use of sync anchor in FileProviderEnumerator
claucambra Mar 7, 2023
ca298ef
Handle version item requests in fetchContents of FileProviderExtensio…
claucambra Mar 7, 2023
53d2fc0
Prevent creation of symbolic link items in FileProviderExtension
claucambra Mar 7, 2023
628ff92
Add a Progress extension with convenience methods for copying progres…
claucambra Mar 7, 2023
17f5298
Properly report progress for download and upload operations in FilePr…
claucambra Mar 7, 2023
a18c6dc
Add convenience method to get all local file metadatas for an account…
claucambra Mar 7, 2023
3316d19
Add convenience method to get local file metadatas for an account in …
claucambra Mar 7, 2023
d22b8e0
Enumerate materialised items when system requests working set
claucambra Mar 7, 2023
cc72cc3
Keep track of additional details about enumerating item in the FilePr…
claucambra Mar 7, 2023
76311cc
Properly handle readFileOrFolder of file vs folder
claucambra Mar 7, 2023
fc376b5
Report deletedItemMetadatas in processItemMetadatasToDelete in Nextcl…
claucambra Mar 8, 2023
a10b563
Report new item metadatas and updated item metadatas in processItemMe…
claucambra Mar 8, 2023
e7e8500
Also report all new, updated, and deleted metadatas from updateItemMe…
claucambra Mar 8, 2023
61dd51a
Properly delete directory and all children when updating folder metad…
claucambra Mar 8, 2023
d478320
Refactor readFileOrFolder to be more adaptible to enumerating items o…
claucambra Mar 9, 2023
7734316
Fix accidental purge of all metadatas caused by trying to call update…
claucambra Mar 9, 2023
60dbf16
Fix the serverUrl used to fetch database item metadatas on enumerateI…
claucambra Mar 9, 2023
53649c2
Rename completeObserver to completeEnumerationObserver
claucambra Mar 9, 2023
2cf4033
Enumerate changes for normal serverUrls in FileProviderEnumerator
claucambra Mar 9, 2023
e2943ab
Delete new updated items that are now E2EE
claucambra Mar 9, 2023
1ffdc5f
Refactor change enumeration completion into separate static function
claucambra Mar 9, 2023
47d50af
Enumerate changed in the working set
claucambra Mar 9, 2023
2b92e9b
Improve handling of nil values in CompleteChangesObserver
claucambra Mar 9, 2023
65ed3ad
Use ocIds for item metadata deletion in NextcloudFilesDatabaseManager
claucambra Mar 9, 2023
25a09e1
Use ocIds for directory metadata deletion, prevent deletion if no suc…
claucambra Mar 9, 2023
03c1731
Handle 404 errors from readFileOrFolder as special deletion case in F…
claucambra Mar 9, 2023
b73c1d7
Better handle initial set up of the file provider extension
claucambra Mar 9, 2023
24b328f
Add method to get all directory metadatas in database manager
claucambra Mar 10, 2023
32e81a6
Add method to get all item metadatas in database manager
claucambra Mar 10, 2023
7302c95
Rewrite working set handling to make it match the server remote, per …
claucambra Mar 10, 2023
b52b821
Enumerate all known folders as workingSet enumeration
claucambra Mar 10, 2023
390403e
Properly report pagination for working set enumeration
claucambra Mar 10, 2023
65ab13c
Ensure we don't saturate the server with propfind requests
claucambra Mar 10, 2023
64e32b4
Add convenience method to get child directories from database manager
claucambra Mar 10, 2023
24d6c50
Create sortedDirectoryMetadatas convenience method in database manager
claucambra Mar 10, 2023
f427750
Ensure metadata handled in FileProviderItem is copy, preventing crash…
claucambra Mar 10, 2023
147e06c
Fix return of updated and deleted metadatas in database manager
claucambra Mar 10, 2023
3e269a9
Fix crash on thread clash with Realm when enumerating changes
claucambra Mar 10, 2023
2ac3a22
Further improve/cleanup/simplify file provider extension init
claucambra Mar 10, 2023
7c8aab3
Fix erroneous deletion of metadata when updating serverUrl subject di…
claucambra Mar 10, 2023
1a48e4e
Fix root cause of threading issues with metadata updates
claucambra Mar 10, 2023
17fea88
Replace full depth scanning of changes on every enumerate changes req…
claucambra Mar 10, 2023
d3f2094
Remove workarounds no longer needed for Realm thread crashing
claucambra Mar 10, 2023
6bfdc10
Use default constructor for private FileProviderDomainManager impleme…
claucambra Mar 10, 2023
2ebd518
Use std::unique_ptr for private implementation class of FileProviderD…
claucambra Mar 10, 2023
f7f6bff
Stop wiping file provider domains on desktop client close/open
claucambra Mar 10, 2023
4e9d51e
Add method to private FileProviderDomainManager to signal enumerator
claucambra Mar 10, 2023
331ce22
Scan for existing file provider domains on FileProviderDomainManager …
claucambra Mar 10, 2023
79d89c2
Ensure no metadatas get deleted when updating metadata for scanned di…
claucambra Mar 10, 2023
0a258f8
Use consistent account ID type in fileproviderdomainmanager
claucambra Mar 11, 2023
b2d76ab
Use push notifications to notify file provider of changes
claucambra Mar 11, 2023
81fb052
Be efficient in working set enumeration by only enumerating for new i…
claucambra Mar 11, 2023
9b4ba22
Use const auto in FileProviderDomainManager
claucambra Mar 11, 2023
1cc0cf7
Fix compatibility with latest NextloudKit version TypeClassFile in NK…
claucambra Mar 11, 2023
d528adf
Sprinkle constness over C++ and Obj-C pointers
claucambra Mar 11, 2023
882e58a
Don't compare un-persisted properties of NextcloudItemMetadataTable i…
claucambra Mar 11, 2023
c4d3c4b
Improve reliability of modifyItem in FileProviderExtension
claucambra Mar 11, 2023
c593bd8
Fix variable related warnings in FileProvider
claucambra Mar 11, 2023
85b9e7d
Modernise Obj-C property notation in fileproviderdomainmanager
claucambra Mar 11, 2023
dcf39aa
Ensure FileProvider gets set up after accountmanager has set up accounts
claucambra Mar 11, 2023
ddd564b
Ensure file provider domain pointers are correctly retained and relea…
claucambra Mar 11, 2023
57f174d
Ensure we wait for check for existing file provider domains to finish…
claucambra Mar 11, 2023
712dde0
Prevent removal of FileProvider domains on app shutdown
claucambra Mar 11, 2023
30b453f
Use specific functions for creating/converting domain identifiers and…
claucambra Mar 11, 2023
bc3fecf
Use asserts to check validity of pointers in private impl of fileprov…
claucambra Mar 11, 2023
7a18d9d
Disconnect the file provider domains when Nextcloud client is closed
claucambra Mar 11, 2023
d6126f4
Make file provider domain disconnection reason string translatable
claucambra Mar 11, 2023
6d1fe0b
Do not send account details to File Provider extension through socket…
claucambra Mar 11, 2023
287a4e4
Unauthenticate the file provider extension when account is logged out
claucambra Mar 11, 2023
178caaa
Allow specifying disconnection of file provider domain message
claucambra Mar 11, 2023
ed4b40b
Disconnect and reconnect file provider domains depending on account s…
claucambra Mar 11, 2023
3ec9968
Move file provider database files into own folder
claucambra Mar 13, 2023
1d15784
Move parentItemIdentifierMetadata helper method to the database manager
claucambra Mar 13, 2023
c24ed9b
Remove isFileSynced function which does not work as intended
claucambra Mar 13, 2023
32e5dba
Rename misleading FileProviderFilesUtils to LocalFilesUtils
claucambra Mar 13, 2023
52f5b6a
Split up the huge NextcloudFilesDatabaseTables file into separate fil…
claucambra Mar 13, 2023
61890dd
Added FileProviderMaterialisedEnumerationObserver to handle clean up …
claucambra Mar 13, 2023
20363bd
Add completion handler to materialised observer
claucambra Mar 13, 2023
d1008df
Respond to materializedItemsDidChange in FileProviderExtension
claucambra Mar 13, 2023
6ef4f8a
Implement better error handling in enumerator changes
claucambra Mar 13, 2023
fdaf0d5
Add NKError extension to make conversion to FileProviderError easier
claucambra Mar 13, 2023
109258f
Use NKError extension method in FileProviderEnumerator enumerate methods
claucambra Mar 13, 2023
a0c819f
Make NKError extension conversion more legible
claucambra Mar 13, 2023
d639bae
Add no changes error code in NKError extension
claucambra Mar 13, 2023
6ffbb5a
Properly handle stopping when finding matching etags in readServerUrl…
claucambra Mar 13, 2023
1ee6d1a
Improve handling of no changes return in readFileOrFolder throughout …
claucambra Mar 13, 2023
3873ad1
Use NKError extension properties instead of magic numbers in FileProv…
claucambra Mar 13, 2023
b9b408d
Fix general error handling in FileProviderEnumerator
claucambra Mar 13, 2023
412fd08
Provide file provider errors in FileProviderExtension methods
claucambra Mar 13, 2023
d31a8be
Ensure registered domains are added and removed at appropriate times …
claucambra Mar 13, 2023
29f346d
Ensure that wipeAllFileProviderDomains doesn't break on macOS 11
claucambra Mar 13, 2023
520e0cf
Add readdFileProviderDomain convenience method to fileproviderdomainm…
claucambra Mar 13, 2023
810fa8d
Handle situations where we might not get a manager for our desired do…
claucambra Mar 13, 2023
002a75b
Add completion handler to readdFileProviderDomain method in fileprovi…
claucambra Mar 13, 2023
89d48ec
Submit tasks to do after readding file provider domain as completion …
claucambra Mar 13, 2023
fd87bff
Signal enumerator after reconnecting file provider domain
claucambra Mar 13, 2023
9dfa3d7
Add some additional converters for domain and account identifiers in …
claucambra Mar 13, 2023
4901b06
Add convenience method to retrieve registered domain ids in private F…
claucambra Mar 13, 2023
bb27188
Use new convenience method to check if push notifications ready for a…
claucambra Mar 13, 2023
017de89
Run poll timer for enumerator signalling to notify accounts without p…
claucambra Mar 13, 2023
2ca2609
Properly write item metadata status update to database in NextcloudFi…
claucambra Mar 14, 2023
b532b96
Add helper itemMetadataLogString static func for logging in Nextcloud…
claucambra Mar 14, 2023
134e373
Do not delete "no longer existing files" when doing enumeration of it…
claucambra Mar 14, 2023
287c98f
Add directoryMetadataLogString convenience method for logging in Next…
claucambra Mar 14, 2023
6804489
Properly respond to errors in working set enumerateItems in FileProvi…
claucambra Mar 14, 2023
7863ba8
Improve error handling in fetchContents if path is not available File…
claucambra Mar 14, 2023
8994f31
Remove unnecessary full reimport after initial account configuration …
claucambra Mar 14, 2023
0f6ceef
Add a logger extensions to use system unified logging in File Provide…
claucambra Mar 14, 2023
b16bf24
Improve logging in files database manager with use of Logger
claucambra Mar 14, 2023
75f18b8
Use enumeration category and logger for FileProviderEnumerator
claucambra Mar 14, 2023
5c72c6a
Replace NSLog in FileProviderExtension with use of Logger
claucambra Mar 14, 2023
854b11e
Use Logger materialisedFileHandling for logging in FileProviderMateri…
claucambra Mar 14, 2023
810c7d0
Also use logger in FileProviderSocketLineProcessor
claucambra Mar 14, 2023
545fe6d
Finish replacing NSLog with use of Logger in LocalFilesUtils
claucambra Mar 14, 2023
3082850
Ensure errors are always publicly displayed in unified logging of Fil…
claucambra Mar 14, 2023
89164d9
Make privacy level of interpolated strings in FileProviderEnumerator …
claucambra Mar 14, 2023
5ae1936
Handle different interpolated string types differently in FileProvide…
claucambra Mar 14, 2023
c88fb7f
Do not hide interpolated log strings in FileProviderSocketLineProcessor
claucambra Mar 14, 2023
7967ced
Properly handle logging interpolation in NextcloudFilesDatabaseManager
claucambra Mar 14, 2023
9083f98
Use completion handler to retrieve updated metadata after status chan…
claucambra Mar 14, 2023
f4be264
Ensure existing metadatas being uploaded are set to uploading status …
claucambra Mar 14, 2023
4e536dc
Ensure upload errors for modified files are recorded in FileProviderE…
claucambra Mar 14, 2023
f16f891
Set deployment target for FileProviderExt to macOS 11.0
claucambra Mar 15, 2023
19dfbd0
Add method to detect if File Provider functionality is available or not
claucambra Mar 15, 2023
6e5c2ee
Do not initialise file provider components if system does not support…
claucambra Mar 15, 2023
d533d2a
Do not try to compile code in FileProviderDomainManager requiring Fil…
claucambra Mar 15, 2023
dbd4de0
Add availability guards around private implementation class of FilePr…
claucambra Mar 15, 2023
23e623e
Make it possible to disable building file provider module
claucambra Mar 15, 2023
b822421
Ensure item upload/download states are properly set and reset in File…
claucambra Mar 15, 2023
5e8d721
Warn when retrieved size of file upload is different to the expected …
claucambra Mar 15, 2023
a761650
Do not copy pause, cancel, and resuming handlers in Progress extensio…
claucambra Mar 15, 2023
d4d5c8f
Removed unused tracking of outstanding session and ocID related tasks
claucambra Mar 15, 2023
607d726
Add ability to set handlers from AlamoFire request on Progress extension
claucambra Mar 15, 2023
221848f
Properly set cancellation, pausing, and resuming handlers on FileProv…
claucambra Mar 15, 2023
8661841
Remove unnecessary local file operations in FileProviderExt
claucambra Mar 15, 2023
762aee8
Simplify temp local file creation while fetching contents, use File P…
claucambra Mar 15, 2023
073db81
Log errors in fetching local temporary file provider path
claucambra Mar 15, 2023
52fe107
Fix blocking main thread when enumerating working set items in FilePr…
claucambra Mar 15, 2023
60005d8
Ensure we are editing realm database on main thread in FileProviderEn…
claucambra Mar 15, 2023
ccad819
Make enumeration of working set changes non-blocking in FileProviderE…
claucambra Mar 15, 2023
22fc43e
Improve initialisation of C++ FileProvider class
claucambra Mar 15, 2023
578e8ea
Clean up FileProviderSocketServer header, remove unnecessary ifdefs
claucambra Mar 15, 2023
6e84aa6
Clean up header for FileProviderSocketController
claucambra Mar 15, 2023
3254595
Do not emit socketDestroyed twice in FileProviderSocketController
claucambra Mar 15, 2023
95c6e7a
Add informative messages after Q_ASSERTs for sockets in FileProviderS…
claucambra Mar 15, 2023
4327b15
Move accountStateFromFileProviderDomainIdentifier to FileProviderDoma…
claucambra Mar 15, 2023
a85d934
Make CMake BUILD_FILE_PROVIDER_MODULE option only available on Apple
claucambra Mar 15, 2023
4f1f438
Rewrite modifyItem to make it non-blocking on the main thread in File…
claucambra Mar 15, 2023
d3c3181
Ensure we are logging error description itself and not NKError wrappe…
claucambra Mar 15, 2023
9fff10f
Do not use QSharedPointer to store FileProviderSocketControllers, use…
claucambra Mar 15, 2023
169b1a7
Use Nextcloud team id.
Ivansss Mar 16, 2023
a859107
Disable automatically manage signing in FileProviderExt target.
Ivansss Mar 16, 2023
ecd55ae
Set CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO in FileProviderExt.
Ivansss Mar 17, 2023
9bcc017
Only set CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO in FileProviderExt for…
Ivansss Mar 17, 2023
0bdbc95
Fix FileProviderExt bundle identifier
claucambra Mar 17, 2023
2c64e4b
Ensure xcodebuild uses the Info.plist file verbatim
claucambra Mar 17, 2023
97d2b35
Ensure we are not marking items as both updated and deleted in FilePr…
claucambra Mar 17, 2023
3538ce9
Change fullRecursiveScan function to enable more than just look for c…
claucambra Mar 17, 2023
2e70c82
Prevent premature running of completion handler when modifying folder…
claucambra Mar 17, 2023
8721862
Remove redundant directory metadata tables in File Provider
claucambra Mar 18, 2023
29b4953
Do not update etags for child folders acquired in a depth 1 readServe…
claucambra Mar 18, 2023
0526079
Fix renaming directories remotely fixing local sync state in file pro…
claucambra Mar 18, 2023
a779fe7
Favour straight return in updateItemMetadatas rather than unnecessary…
claucambra Mar 18, 2023
b2d2f95
Properly report deleted metadatas in recursive directory delete in Fi…
claucambra Mar 18, 2023
245129d
Move remote sync stuff in FileProviderEnumerator to own file
claucambra Mar 18, 2023
3c2c360
Properly report and handle critical errors during recursive enumerati…
claucambra Mar 18, 2023
d0b4b68
Move deleted/updated conflict check to fullRecursiveScan in FileProvi…
claucambra Mar 18, 2023
213893b
Fix recursive scan when scanChangesOnly is false in FileProviderEnume…
claucambra Mar 18, 2023
b369b5d
Handle invalidation of enumerator during long recursive scans in File…
claucambra Mar 18, 2023
8c729fb
Simplify enumerateItems of working set by using fullRecursiveScan in …
claucambra Mar 18, 2023
6202f3d
Split metadata parsing to complete enumerator into own function
claucambra Mar 18, 2023
5154a57
Move conversion from NSData to NSFileProviderPage to separate func
claucambra Mar 18, 2023
1524fc0
Progressively enumerate items as we get them for working set
claucambra Mar 18, 2023
35570a3
Move remote sync functionality out of enumerator and into separate Ne…
claucambra Mar 18, 2023
289f7f2
Ensure we do not set etag if we have set updateDirectoryEtags to fals…
claucambra Mar 18, 2023
9cc0545
Do not do specific enumeration of items working set in FileProviderEn…
claucambra Mar 18, 2023
02e1d6a
Fix recursive directory metadata renaming order
claucambra Mar 18, 2023
9fadc89
Fix unsetting of etags on directories (and only) directories on update
claucambra Mar 18, 2023
34a43fe
Make sure to notify when folder moved in FileProviderExtension
claucambra Mar 18, 2023
27a177a
Make sure to include new metadatas in folders to scan for changes in …
claucambra Mar 18, 2023
384093c
Remove redundant double read of serverUrl when often we always want t…
claucambra Mar 18, 2023
808f976
Fix children serverurl rename in file provider nc files database
claucambra Mar 18, 2023
fe7ca12
Perform slow metadata to FileProviderItem conversion concurrently in …
claucambra Mar 18, 2023
bd50f75
Simplify initial item enumeration, no need to fetch from database in …
claucambra Mar 18, 2023
9c1a035
Reintegrate sync engine into FileProviderEnumerator class
claucambra Mar 18, 2023
6169594
Prevent multi-thread modification of the same array with serial array…
claucambra Mar 20, 2023
2853b88
Move NKFile to metadata conversion methods to a new extension for Nex…
claucambra Mar 20, 2023
c088f0e
Fix recursive metadata delete in NextcloudFilesDatabaseManager
claucambra Mar 20, 2023
7550ed7
Properly handle metadata delete after item deletion in FileProviderEx…
claucambra Mar 20, 2023
766ecf4
Parallelise conversion of NKFiles to NextcloudItemMetadataTables
claucambra Mar 20, 2023
67daae2
Ensure we return deleted metadata directory copy rather than live fir…
claucambra Mar 20, 2023
a7344ba
Fix unused/unmodified variable definition warnings in FileProviderEnu…
claucambra Mar 20, 2023
0f578fa
Use specific signalEnumerator method in FileProviderExtension item re…
claucambra Mar 20, 2023
f37e7cc
Remove readdFileProviderDomain hack in FileProviderDomainManager
claucambra Mar 20, 2023
ebf96e3
Make NKError extension code more Swift-like, clean up
claucambra Mar 21, 2023
7e1ebed
Split client interfacing code into FileProviderExtension extension
claucambra Mar 21, 2023
e245ec0
Set interpolated log strings in FileProvider logs to public
claucambra Mar 21, 2023
2c3fa71
Rename FileProviderDomainManager::Private to FileProviderDomainManage…
claucambra Mar 22, 2023
3d6acb5
Use consistent if defined in application.cpp
claucambra Mar 22, 2023
6797e12
Properly report modification date for FileProviderItem
claucambra Apr 3, 2023
0c78630
Fix query of childDirectoriesForDirectory in NextcloudFilesDatabaseMa…
claucambra Apr 4, 2023
16a28a7
Add convenience method for NextcloudFilesDatabaseManager to get child…
claucambra Apr 4, 2023
2b55b43
Correctly report child item count for folders in FileProviderItem
claucambra Apr 4, 2023
4cb1e08
Split directory item metadata handling in database to new NextcloudFi…
claucambra Apr 4, 2023
486c1a2
Split local file related metadata management into own extension in Ne…
claucambra Apr 4, 2023
7d47e23
Add convenience method to get thumbnailUrl in NextcloudItemMetadataTable
claucambra Apr 4, 2023
ace8dbc
Add support for thumbnails in FileProviderExtension
claucambra Apr 6, 2023
ab070fc
Add config entry for file provider module enabling
claucambra May 12, 2023
246347f
Do not initialise file provider module if not enabled in config
claucambra May 12, 2023
b7d9826
Build macOS shell extensions with debug configuration in xcodebuild w…
claucambra May 12, 2023
23855a1
Do not exclude file provider config entries from compile on non-macOS…
claucambra May 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ dlldata.c
# macOS specific
xcuserdata/
**/.DS_Store
**/Carthage/

# Visual C++ cache files
ipch/
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ else()
unset(CMAKE_CXX_CLANG_TIDY)
endif()

if (APPLE)
# build macOS File Provider module
option(BUILD_FILE_PROVIDER_MODULE "BUILD_FILE_PROVIDER_MODULE" ON)
endif()

# When this option is enabled, 5xx errors are not added to the blacklist
# Normally you don't want to enable this option because if a particular file
# triggers a bug on the server, you want the file to be blacklisted.
Expand Down
71 changes: 50 additions & 21 deletions shell_integration/MacOSX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
if(APPLE)
set(OC_OEM_SHARE_ICNS "${CMAKE_BINARY_DIR}/src/gui/${APPLICATION_ICON_NAME}.icns")
set(OC_OEM_SHARE_ICNS "${CMAKE_BINARY_DIR}/src/gui/${APPLICATION_ICON_NAME}.icns")

# The bundle identifier and application group need to have compatible values with the client
# to be able to open a Mach port across the extension's sandbox boundary.
# Pass the info through the xcodebuild command line and make sure that the project uses
# those user-defined settings to build the plist.
add_custom_target( mac_overlayplugin ALL
xcodebuild ARCHS=${CMAKE_OSX_ARCHITECTURES} ONLY_ACTIVE_ARCH=NO
-project ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/OwnCloudFinderSync/OwnCloudFinderSync.xcodeproj
-target FinderSyncExt -configuration Release "SYMROOT=${CMAKE_CURRENT_BINARY_DIR}"
"OC_OEM_SHARE_ICNS=${OC_OEM_SHARE_ICNS}"
"OC_APPLICATION_NAME=${APPLICATION_NAME}"
"OC_APPLICATION_REV_DOMAIN=${APPLICATION_REV_DOMAIN}"
"OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}"
COMMENT building Mac Overlay icons
VERBATIM)
add_dependencies(mac_overlayplugin nextcloud) # for the ownCloud.icns to be generated
if (CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
set(XCODE_TARGET_CONFIGURATION "Debug")
else()
set(XCODE_TARGET_CONFIGURATION "Release")
endif()

if (BUILD_OWNCLOUD_OSX_BUNDLE)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/FinderSyncExt.appex
DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/PlugIns
USE_SOURCE_PERMISSIONS)
endif()
# The bundle identifier and application group need to have compatible values with the client
# to be able to open a Mach port across the extension's sandbox boundary.
# Pass the info through the xcodebuild command line and make sure that the project uses
# those user-defined settings to build the plist.
add_custom_target( mac_overlayplugin ALL
xcodebuild ARCHS=${CMAKE_OSX_ARCHITECTURES} ONLY_ACTIVE_ARCH=NO
-project ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj
-target FinderSyncExt -configuration ${XCODE_TARGET_CONFIGURATION} "SYMROOT=${CMAKE_CURRENT_BINARY_DIR}"
"OC_OEM_SHARE_ICNS=${OC_OEM_SHARE_ICNS}"
"OC_APPLICATION_NAME=${APPLICATION_NAME}"
"OC_APPLICATION_REV_DOMAIN=${APPLICATION_REV_DOMAIN}"
"OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}"
COMMENT building Mac Overlay icons
VERBATIM)

if (BUILD_FILE_PROVIDER_MODULE)
add_custom_target( mac_fileproviderplugin ALL
xcodebuild ARCHS=${CMAKE_OSX_ARCHITECTURES} ONLY_ACTIVE_ARCH=NO
-project ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj
-target FileProviderExt -configuration ${XCODE_TARGET_CONFIGURATION} "SYMROOT=${CMAKE_CURRENT_BINARY_DIR}"
"OC_APPLICATION_EXECUTABLE_NAME=${APPLICATION_EXECUTABLE}"
"OC_APPLICATION_VENDOR=${APPLICATION_VENDOR}"
"OC_APPLICATION_NAME=${APPLICATION_NAME}"
"OC_APPLICATION_REV_DOMAIN=${APPLICATION_REV_DOMAIN}"
"OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}"
COMMENT building macOS File Provider extension
VERBATIM)

add_dependencies(mac_overlayplugin mac_fileproviderplugin nextcloud) # for the ownCloud.icns to be generated
else()
add_dependencies(mac_overlayplugin nextcloud) # for the ownCloud.icns to be generated
endif()

if (BUILD_OWNCLOUD_OSX_BUNDLE)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/FinderSyncExt.appex
DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/PlugIns
USE_SOURCE_PERMISSIONS)

if (BUILD_FILE_PROVIDER_MODULE)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/FileProviderExt.appex
DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/PlugIns
USE_SOURCE_PERMISSIONS)
endif()
endif()
endif()

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright (C) 2023 by Claudio Cambra <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

import Foundation
import OSLog

extension NextcloudFilesDatabaseManager {
func directoryMetadata(account: String, serverUrl: String) -> NextcloudItemMetadataTable? {
// We want to split by "/" (e.g. cloud.nc.com/files/a/b) but we need to be mindful of "https://c.nc.com"
let problematicSeparator = "://"
let placeholderSeparator = "__TEMP_REPLACE__"
let serverUrlWithoutPrefix = serverUrl.replacingOccurrences(of: problematicSeparator, with: placeholderSeparator)
var splitServerUrl = serverUrlWithoutPrefix.split(separator: "/")
let directoryItemFileName = String(splitServerUrl.removeLast())
let directoryItemServerUrl = splitServerUrl.joined(separator: "/").replacingOccurrences(of: placeholderSeparator, with: problematicSeparator)

if let metadata = ncDatabase().objects(NextcloudItemMetadataTable.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND directory == true", account, directoryItemServerUrl, directoryItemFileName).first {
return NextcloudItemMetadataTable(value: metadata)
}

return nil
}

func childItemsForDirectory(_ directoryMetadata: NextcloudItemMetadataTable) -> [NextcloudItemMetadataTable] {
let directoryServerUrl = directoryMetadata.serverUrl + "/" + directoryMetadata.fileName
let metadatas = ncDatabase().objects(NextcloudItemMetadataTable.self).filter("serverUrl BEGINSWITH %@", directoryServerUrl)
return sortedItemMetadatas(metadatas)
}

func childDirectoriesForDirectory(_ directoryMetadata: NextcloudItemMetadataTable) -> [NextcloudItemMetadataTable] {
let directoryServerUrl = directoryMetadata.serverUrl + "/" + directoryMetadata.fileName
let metadatas = ncDatabase().objects(NextcloudItemMetadataTable.self).filter("serverUrl BEGINSWITH %@ AND directory == true", directoryServerUrl)
return sortedItemMetadatas(metadatas)
}

func parentDirectoryMetadataForItem(_ itemMetadata: NextcloudItemMetadataTable) -> NextcloudItemMetadataTable? {
return directoryMetadata(account: itemMetadata.account, serverUrl: itemMetadata.serverUrl)
}

func directoryMetadata(ocId: String) -> NextcloudItemMetadataTable? {
if let metadata = ncDatabase().objects(NextcloudItemMetadataTable.self).filter("ocId == %@ AND directory == true", ocId).first {
return NextcloudItemMetadataTable(value: metadata)
}

return nil
}

func directoryMetadatas(account: String) -> [NextcloudItemMetadataTable] {
let metadatas = ncDatabase().objects(NextcloudItemMetadataTable.self).filter("account == %@ AND directory == true", account)
return sortedItemMetadatas(metadatas)
}

func directoryMetadatas(account: String, parentDirectoryServerUrl: String) -> [NextcloudItemMetadataTable] {
let metadatas = ncDatabase().objects(NextcloudItemMetadataTable.self).filter("account == %@ AND parentDirectoryServerUrl == %@ AND directory == true", account, parentDirectoryServerUrl)
return sortedItemMetadatas(metadatas)
}

// Deletes all metadatas related to the info of the directory provided
func deleteDirectoryAndSubdirectoriesMetadata(ocId: String) -> [NextcloudItemMetadataTable]? {
let database = ncDatabase()
guard let directoryMetadata = database.objects(NextcloudItemMetadataTable.self).filter("ocId == %@ AND directory == true", ocId).first else {
Logger.ncFilesDatabase.error("Could not find directory metadata for ocId \(ocId, privacy: .public). Not proceeding with deletion")
return nil
}

let directoryMetadataCopy = NextcloudItemMetadataTable(value: directoryMetadata)
let directoryUrlPath = directoryMetadata.serverUrl + "/" + directoryMetadata.fileName
let directoryAccount = directoryMetadata.account
let directoryEtag = directoryMetadata.etag

Logger.ncFilesDatabase.debug("Deleting root directory metadata in recursive delete. ocID: \(directoryMetadata.ocId, privacy: .public), etag: \(directoryEtag, privacy: .public), serverUrl: \(directoryUrlPath, privacy: .public)")

guard deleteItemMetadata(ocId: directoryMetadata.ocId) else {
Logger.ncFilesDatabase.debug("Failure to delete root directory metadata in recursive delete. ocID: \(directoryMetadata.ocId, privacy: .public), etag: \(directoryEtag, privacy: .public), serverUrl: \(directoryUrlPath, privacy: .public)")
return nil
}

var deletedMetadatas: [NextcloudItemMetadataTable] = [directoryMetadataCopy]

let results = database.objects(NextcloudItemMetadataTable.self).filter("account == %@ AND serverUrl BEGINSWITH %@", directoryAccount, directoryUrlPath)

for result in results {
let successfulItemMetadataDelete = deleteItemMetadata(ocId: result.ocId)
if (successfulItemMetadataDelete) {
deletedMetadatas.append(NextcloudItemMetadataTable(value: result))
}

if localFileMetadataFromOcId(result.ocId) != nil {
deleteLocalFileMetadata(ocId: result.ocId)
}
}

Logger.ncFilesDatabase.debug("Completed deletions in directory recursive delete. ocID: \(directoryMetadata.ocId, privacy: .public), etag: \(directoryEtag, privacy: .public), serverUrl: \(directoryUrlPath, privacy: .public)")

return deletedMetadatas
}

func renameDirectoryAndPropagateToChildren(ocId: String, newServerUrl: String, newFileName: String) -> [NextcloudItemMetadataTable]? {

let database = ncDatabase()

guard let directoryMetadata = database.objects(NextcloudItemMetadataTable.self).filter("ocId == %@ AND directory == true", ocId).first else {
Logger.ncFilesDatabase.error("Could not find a directory with ocID \(ocId, privacy: .public), cannot proceed with recursive renaming")
return nil
}

let oldItemServerUrl = directoryMetadata.serverUrl
let oldDirectoryServerUrl = oldItemServerUrl + "/" + directoryMetadata.fileName
let newDirectoryServerUrl = newServerUrl + "/" + newFileName
let childItemResults = database.objects(NextcloudItemMetadataTable.self).filter("account == %@ AND serverUrl BEGINSWITH %@", directoryMetadata.account, oldDirectoryServerUrl)

renameItemMetadata(ocId: ocId, newServerUrl: newServerUrl, newFileName: newFileName)
Logger.ncFilesDatabase.debug("Renamed root renaming directory")

do {
try database.write {
for childItem in childItemResults {
let oldServerUrl = childItem.serverUrl
let movedServerUrl = oldServerUrl.replacingOccurrences(of: oldDirectoryServerUrl, with: newDirectoryServerUrl)
childItem.serverUrl = movedServerUrl
database.add(childItem, update: .all)
Logger.ncFilesDatabase.debug("Moved childItem at \(oldServerUrl) to \(movedServerUrl)")
}
}
} catch let error {
Logger.ncFilesDatabase.error("Could not rename directory metadata with ocId: \(ocId, privacy: .public) to new serverUrl: \(newServerUrl), received error: \(error.localizedDescription, privacy: .public)")

return nil
}

let updatedChildItemResults = database.objects(NextcloudItemMetadataTable.self).filter("account == %@ AND serverUrl BEGINSWITH %@", directoryMetadata.account, newDirectoryServerUrl)
return sortedItemMetadatas(updatedChildItemResults)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2023 by Claudio Cambra <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

import Foundation
import RealmSwift
import OSLog

extension NextcloudFilesDatabaseManager {
func localFileMetadataFromOcId(_ ocId: String) -> NextcloudLocalFileMetadataTable? {
if let metadata = ncDatabase().objects(NextcloudLocalFileMetadataTable.self).filter("ocId == %@", ocId).first {
return NextcloudLocalFileMetadataTable(value: metadata)
}

return nil
}

func addLocalFileMetadataFromItemMetadata(_ itemMetadata: NextcloudItemMetadataTable) {
let database = ncDatabase()

do {
try database.write {
let newLocalFileMetadata = NextcloudLocalFileMetadataTable()

newLocalFileMetadata.ocId = itemMetadata.ocId
newLocalFileMetadata.fileName = itemMetadata.fileName
newLocalFileMetadata.account = itemMetadata.account
newLocalFileMetadata.etag = itemMetadata.etag
newLocalFileMetadata.exifDate = Date()
newLocalFileMetadata.exifLatitude = "-1"
newLocalFileMetadata.exifLongitude = "-1"

database.add(newLocalFileMetadata, update: .all)
Logger.ncFilesDatabase.debug("Added local file metadata from item metadata. ocID: \(itemMetadata.ocId, privacy: .public), etag: \(itemMetadata.etag, privacy: .public), fileName: \(itemMetadata.fileName, privacy: .public)")
}
} catch let error {
Logger.ncFilesDatabase.error("Could not add local file metadata from item metadata. ocID: \(itemMetadata.ocId, privacy: .public), etag: \(itemMetadata.etag, privacy: .public), fileName: \(itemMetadata.fileName, privacy: .public), received error: \(error.localizedDescription, privacy: .public)")
}
}

func deleteLocalFileMetadata(ocId: String) {
let database = ncDatabase()

do {
try database.write {
let results = database.objects(NextcloudLocalFileMetadataTable.self).filter("ocId == %@", ocId)
database.delete(results)
}
} catch let error {
Logger.ncFilesDatabase.error("Could not delete local file metadata with ocId: \(ocId, privacy: .public), received error: \(error.localizedDescription, privacy: .public)")
}
}

private func sortedLocalFileMetadatas(_ metadatas: Results<NextcloudLocalFileMetadataTable>) -> [NextcloudLocalFileMetadataTable] {
let sortedMetadatas = metadatas.sorted(byKeyPath: "fileName", ascending: true)
return Array(sortedMetadatas.map { NextcloudLocalFileMetadataTable(value: $0) })
}

func localFileMetadatas(account: String) -> [NextcloudLocalFileMetadataTable] {
let results = ncDatabase().objects(NextcloudLocalFileMetadataTable.self).filter("account == %@", account)
return sortedLocalFileMetadatas(results)
}

func localFileItemMetadatas(account: String) -> [NextcloudItemMetadataTable] {
let localFileMetadatas = localFileMetadatas(account: account)
let localFileMetadatasOcIds = Array(localFileMetadatas.map { $0.ocId })

var itemMetadatas: [NextcloudItemMetadataTable] = []

for ocId in localFileMetadatasOcIds {
guard let itemMetadata = itemMetadataFromOcId(ocId) else {
Logger.ncFilesDatabase.error("Could not find matching item metadata for local file metadata with ocId: \(ocId, privacy: .public) with request from account: \(account)")
continue;
}

itemMetadatas.append(NextcloudItemMetadataTable(value: itemMetadata))
}

return itemMetadatas
}
}
Loading