mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 19:58:56 +03:00
Ensure we are not marking items as both updated and deleted in FileProviderEnumerator
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
2c64e4b6bd
commit
97d2b354df
1 changed files with 15 additions and 11 deletions
|
@ -110,11 +110,6 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
for directoryMetadata in directoryMetadatas {
|
for directoryMetadata in directoryMetadatas {
|
||||||
guard directoryMetadata.etag != "" else {
|
|
||||||
Logger.enumeration.info("Skipping enumeration of unexplored directory for working set: \(directoryMetadata.serverUrl, privacy: OSLogPrivacy.auto(mask: .hash))")
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatchGroup.enter() // Add to outer counter
|
dispatchGroup.enter() // Add to outer counter
|
||||||
|
|
||||||
dispatchQueue.async {
|
dispatchQueue.async {
|
||||||
|
@ -249,12 +244,26 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||||
FileProviderEnumerator.fullRecursiveScanForChanges(ncAccount: self.ncAccount, ncKit: self.ncKit) { newMetadatas, updatedMetadatas, deletedMetadatas in
|
FileProviderEnumerator.fullRecursiveScanForChanges(ncAccount: self.ncAccount, ncKit: self.ncKit) { newMetadatas, updatedMetadatas, deletedMetadatas in
|
||||||
|
|
||||||
Logger.enumeration.info("Finished recursive change enumeration of working set for user: \(self.ncAccount.ncKitAccount, privacy: OSLogPrivacy.auto(mask: .hash)). Enumerating items.")
|
Logger.enumeration.info("Finished recursive change enumeration of working set for user: \(self.ncAccount.ncKitAccount, privacy: OSLogPrivacy.auto(mask: .hash)). Enumerating items.")
|
||||||
|
|
||||||
|
// Run a check to ensure files deleted in one location are not updated in another (e.g. when moved)
|
||||||
|
// The recursive scan provides us with updated/deleted metadatas only on a folder by folder basis;
|
||||||
|
// so we need to check we are not simultaneously marking a moved file as deleted and updated
|
||||||
|
var checkedDeletedMetadatas = deletedMetadatas
|
||||||
|
|
||||||
|
for updatedMetadata in updatedMetadatas {
|
||||||
|
guard let matchingDeletedMetadataIdx = checkedDeletedMetadatas.firstIndex(where: { $0.ocId == updatedMetadata.ocId } ) else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkedDeletedMetadatas.remove(at: matchingDeletedMetadataIdx)
|
||||||
|
}
|
||||||
|
|
||||||
FileProviderEnumerator.completeChangesObserver(observer,
|
FileProviderEnumerator.completeChangesObserver(observer,
|
||||||
anchor: anchor,
|
anchor: anchor,
|
||||||
ncKit: self.ncKit,
|
ncKit: self.ncKit,
|
||||||
newMetadatas: newMetadatas,
|
newMetadatas: newMetadatas,
|
||||||
updatedMetadatas: updatedMetadatas,
|
updatedMetadatas: updatedMetadatas,
|
||||||
deletedMetadatas: deletedMetadatas)
|
deletedMetadatas: checkedDeletedMetadatas)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
} else if enumeratedItemIdentifier == .trashContainer {
|
} else if enumeratedItemIdentifier == .trashContainer {
|
||||||
|
@ -429,11 +438,6 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||||
|
|
||||||
private static func scanRecursivelyForChanges(_ directoryMetadata: NextcloudDirectoryMetadataTable, ncAccount: NextcloudAccount, ncKit: NextcloudKit) -> (newMetadatas: [NextcloudItemMetadataTable], updatedMetadatas: [NextcloudItemMetadataTable], deletedMetadatas: [NextcloudItemMetadataTable]) {
|
private static func scanRecursivelyForChanges(_ directoryMetadata: NextcloudDirectoryMetadataTable, ncAccount: NextcloudAccount, ncKit: NextcloudKit) -> (newMetadatas: [NextcloudItemMetadataTable], updatedMetadatas: [NextcloudItemMetadataTable], deletedMetadatas: [NextcloudItemMetadataTable]) {
|
||||||
|
|
||||||
guard directoryMetadata.etag != "" || directoryMetadata.serverUrl == ncAccount.davFilesUrl else {
|
|
||||||
Logger.enumeration.info("Skipping enumeration of changes in unexplored directory for working \(directoryMetadata.serverUrl, privacy: OSLogPrivacy.auto(mask: .hash))")
|
|
||||||
return ([], [], [])
|
|
||||||
}
|
|
||||||
|
|
||||||
var allNewMetadatas: [NextcloudItemMetadataTable] = []
|
var allNewMetadatas: [NextcloudItemMetadataTable] = []
|
||||||
var allUpdatedMetadatas: [NextcloudItemMetadataTable] = []
|
var allUpdatedMetadatas: [NextcloudItemMetadataTable] = []
|
||||||
var allDeletedMetadatas: [NextcloudItemMetadataTable] = []
|
var allDeletedMetadatas: [NextcloudItemMetadataTable] = []
|
||||||
|
|
Loading…
Reference in a new issue