mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 11:48:56 +03:00
Do not delete "no longer existing files" when doing enumeration of items in FileProviderEnumerator
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
b532b96937
commit
134e373f1b
1 changed files with 4 additions and 7 deletions
|
@ -81,6 +81,10 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||||
|
|
||||||
let dbManager = NextcloudFilesDatabaseManager.shared
|
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 enumeratedItemIdentifier == .workingSet && dbManager.anyItemMetadatasForAccount(ncAccount.ncKitAccount) {
|
||||||
if page == NSFileProviderPage.initialPageSortedByDate as NSFileProviderPage ||
|
if page == NSFileProviderPage.initialPageSortedByDate as NSFileProviderPage ||
|
||||||
page == NSFileProviderPage.initialPageSortedByName 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
|
FileProviderEnumerator.readServerUrl(directoryMetadata.serverUrl, ncAccount: ncAccount, ncKit: ncKit) { metadatas, _, _, _, readError in
|
||||||
guard readError == nil else {
|
guard readError == nil else {
|
||||||
NSLog("Finishing enumeration of working set directory %@ with error %@", directoryMetadata.serverUrl, readError!.localizedDescription)
|
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()
|
dispatchGroup.leave()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue