From 134e373f1bd4f548a5483b4c45eb67d3ae629108 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 14 Mar 2023 16:01:34 +0100 Subject: [PATCH] Do not delete "no longer existing files" when doing enumeration of items in FileProviderEnumerator Signed-off-by: Claudio Cambra --- .../FileProviderExt/FileProviderEnumerator.swift | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift index 85fe33d2e..c7ef8d7b6 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift @@ -81,6 +81,10 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { let dbManager = NextcloudFilesDatabaseManager.shared + // If we don't have any items in the database, ignore this and go for a normal serverUrl read. + // By default we set the serverUrl to be the webdav files root when we are provided a system container id. + // However, if we do have items, we want to do a recursive scan of all the folders in the server that + // ** we have already explored ** . This is to not kill the server. if enumeratedItemIdentifier == .workingSet && dbManager.anyItemMetadatasForAccount(ncAccount.ncKitAccount) { if page == NSFileProviderPage.initialPageSortedByDate as NSFileProviderPage || page == NSFileProviderPage.initialPageSortedByName as NSFileProviderPage { @@ -102,13 +106,6 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { FileProviderEnumerator.readServerUrl(directoryMetadata.serverUrl, ncAccount: ncAccount, ncKit: ncKit) { metadatas, _, _, _, readError in guard readError == nil else { NSLog("Finishing enumeration of working set directory %@ with error %@", directoryMetadata.serverUrl, readError!.localizedDescription) - - let nkReadError = NKError(error: readError!) - if nkReadError.isNotFoundError { - NSLog("404 error means item no longer exists. Deleting metadata and reporting as deletion without error") - dbManager.deleteDirectoryAndSubdirectoriesMetadata(ocId: directoryMetadata.ocId) - } - dispatchGroup.leave() return }