Remove isFileSynced function which does not work as intended
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 13 Mar 2023 11:37:59 +0000 (12:37 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 12 May 2023 05:21:29 +0000 (13:21 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderItem.swift
shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudFileProviderFilesUtils.swift

index 2022791dbdcd056ce01ba2529d48fb763dff786b..04c05453568e08b944a3fb0cc0fe5ecdf6e11edb 100644 (file)
@@ -82,7 +82,7 @@ class FileProviderItem: NSObject, NSFileProviderItem {
     }
 
     var isDownloaded: Bool {
-        return metadata.directory || isFileSynced(metadata: metadata)
+        return metadata.directory || NextcloudFilesDatabaseManager.shared.localFileMetadataFromOcId(metadata.ocId) != nil
     }
 
     var isDownloading: Bool {
index dc70f779b202ccd93f31a8ebd9fd8f99b9acf1db..411542a77b5d60b069fca76689db332f44937938 100644 (file)
@@ -88,18 +88,3 @@ func createFileOrDirectoryLocally(metadata: NextcloudItemMetadataTable) {
         NSLog("Could not create NC file or directory locally, received error: %@", error.localizedDescription)
     }
 }
-
-func isFileSynced(metadata: NextcloudItemMetadataTable) -> Bool {
-    guard metadata.directory else { return false }
-    do {
-        let localPathForFile = try localPathForNCFile(itemMetadata: metadata)
-        let localFileAttributes = try FileManager.default.attributesOfItem(atPath: localPathForFile.path)
-        let localFileSize = localFileAttributes[.size] as? Int64
-
-        return localFileSize == metadata.size
-    } catch let error {
-        NSLog("Could not check if file %@ is synced, received error: %@", metadata.fileNameView, error.localizedDescription)
-    }
-
-    return false
-}