Only try upload of modified item in FileProviderExtension if that had its contents changed and we have a valid content url

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-06 16:58:36 +01:00
parent 0f2fbf7518
commit 020c5d5104
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -396,13 +396,25 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
completionHandler(fpItem, [], false, nil) completionHandler(fpItem, [], false, nil)
} }
if itemTemplateIsFolder {
NSLog("Only handling renaming for folders. ocId: %@", item.itemIdentifier.rawValue)
return Progress() return Progress()
} else if itemTemplateIsFolder { }
}
guard !itemTemplateIsFolder else {
NSLog("System requested modification for folder with ocID %@ (%@) of something other than folder name.", item.itemIdentifier.rawValue, newServerUrlFileName) NSLog("System requested modification for folder with ocID %@ (%@) of something other than folder name.", item.itemIdentifier.rawValue, newServerUrlFileName)
completionHandler(item, [], false, nil) completionHandler(item, [], false, nil)
return Progress() return Progress()
} }
if changedFields.contains(.contents) {
guard newContents != nil else {
NSLog("WARNING. Could not upload modified contents as was provided nil contents url. ocId: %@", item.itemIdentifier.rawValue)
completionHandler(item, [], false, NSFileProviderError(.noSuchItem))
return Progress()
}
self.ncKit.upload(serverUrlFileName: newServerUrlFileName, self.ncKit.upload(serverUrlFileName: newServerUrlFileName,
fileNameLocalPath: fileNameLocalPath, fileNameLocalPath: fileNameLocalPath,
requestHandler: { _ in requestHandler: { _ in
@ -445,6 +457,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
completionHandler(fpItem, [], false, nil) completionHandler(fpItem, [], false, nil)
} }
}
return Progress() return Progress()
} }