Skip to content

Commit

Permalink
Handle post-trash-restore case where scanned restore path returns dif…
Browse files Browse the repository at this point in the history
…ferent file

When restoring from trash to a location that already has a file with the
same name, this may happen

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
  • Loading branch information
claucambra committed Dec 11, 2024
1 parent c69c44b commit 9353a68
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/NextcloudFileProviderKit/Item/Item+Modify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,17 @@ public extension Item {
return (modifiedItem, enumerateError.fileProviderError)
}

guard target.ocId == modifiedItem.itemIdentifier.rawValue else {
Self.logger.error(
"""
Restored item \(originalLocation, privacy: .public)
does not match \(modifiedItem.filename, privacy: .public)
(it is likely that when restoring from the trash, there was another identical item).
"""
) // TODO: Be more permissive of this and just rescan remote state
return (modifiedItem, NSFileProviderError(.cannotSynchronize))
}

let restoredItemMetadata = ItemMetadata.fromNKFile(target, account: account)
guard let parentItemIdentifier = dbManager.parentItemIdentifierFromMetadata(
restoredItemMetadata
Expand Down

0 comments on commit 9353a68

Please sign in to comment.