From: Claudio Cambra Date: Wed, 15 Mar 2023 10:27:14 +0000 (+0100) Subject: Warn when retrieved size of file upload is different to the expected size in FileProv... X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~10^2~55^2~81 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5e8d7217a921b392b05724c3e6c7a023342d4891;p=nextcloud-desktop.git Warn when retrieved size of file upload is different to the expected size in FileProviderExtension Signed-off-by: Claudio Cambra --- diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift index b99a318ab..85894382b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift @@ -308,7 +308,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm }) { account, ocId, etag, date, size, _, _, error in self.outstandingSessionTasks.removeValue(forKey: newServerUrlFileName) - guard error == .success, let ocId = ocId/*, size == itemTemplate.documentSize as! Int64*/ else { + guard error == .success, let ocId = ocId else { Logger.fileTransfer.error("Could not upload item with filename: \(itemTemplate.filename, privacy: OSLogPrivacy.auto(mask: .hash)), received error: \(error, privacy: .public)") completionHandler(itemTemplate, [], false, error.toFileProviderError()) return @@ -316,6 +316,10 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm Logger.fileTransfer.info("Successfully uploaded item with identifier: \(ocId, privacy: .public) and filename: \(itemTemplate.filename, privacy: OSLogPrivacy.auto(mask: .hash))") + if size != itemTemplate.documentSize as? Int64 { + Logger.fileTransfer.warning("Created item upload reported as successful, but there are differences between the received file size (\(size, privacy: .public)) and the original file size (\(itemTemplate.documentSize ?? 0))") + } + let newMetadata = NextcloudItemMetadataTable() newMetadata.date = (date ?? NSDate()) as Date newMetadata.etag = etag ?? "" @@ -499,6 +503,10 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm if error == .success, let ocId = ocId { Logger.fileProviderExtension.info("Successfully uploaded item with identifier: \(ocId, privacy: .public) and filename: \(item.filename, privacy: OSLogPrivacy.auto(mask: .hash))") + if size != item.documentSize as? Int64 { + Logger.fileTransfer.warning("Created item upload reported as successful, but there are differences between the received file size (\(size, privacy: .public)) and the original file size (\(item.documentSize ?? 0))") + } + let newMetadata = NextcloudItemMetadataTable() newMetadata.date = (date ?? NSDate()) as Date newMetadata.etag = etag ?? ""