Marino Faggiana 1 жил өмнө
parent
commit
e63ac4128b

+ 1 - 1
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -1148,7 +1148,7 @@ extension NCManageDatabase {
     func isDownloadMetadata(_ metadata: tableMetadata, download: Bool) -> Bool {
 
         let localFile = getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-        let fileSize = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
+        let fileSize = NCUtilityFileSystem.shared.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
         if (localFile != nil || download) && (localFile?.etag != metadata.etag || fileSize == 0) {
             return true
         }

+ 0 - 1
iOSClient/Utility/CCUtility.h

@@ -49,7 +49,6 @@
 
 + (void)createDirectoryStandard;
 
-+ (int64_t)fileProviderStorageSize:(NSString *)ocId fileNameView:(NSString *)fileNameView;
 + (BOOL)fileProviderStoragePreviewIconExists:(NSString *)ocId etag:(NSString *)etag;
 
 + (void)removeGroupApplicationSupport;

+ 1 - 1
iOSClient/Utility/NCUtility.swift

@@ -377,7 +377,7 @@ class NCUtility: NSObject {
         let fileNamePathPreview = NCUtilityFileSystem.shared.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag)
         let fileNamePathIcon = NCUtilityFileSystem.shared.getDirectoryProviderStorageIconOcId(ocId, etag: etag)
 
-        if CCUtility.fileProviderStorageSize(ocId, fileNameView: fileNameView) > 0 && FileManager().fileExists(atPath: fileNamePathPreview) && FileManager().fileExists(atPath: fileNamePathIcon) { return }
+        if NCUtilityFileSystem.shared.fileProviderStorageSize(ocId, fileNameView: fileNameView) > 0 && FileManager().fileExists(atPath: fileNamePathPreview) && FileManager().fileExists(atPath: fileNamePathIcon) { return }
         if classFile != NKCommon.TypeClassFile.image.rawValue && classFile != NKCommon.TypeClassFile.video.rawValue { return }
 
         if classFile == NKCommon.TypeClassFile.image.rawValue {

+ 13 - 3
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -143,13 +143,23 @@ class NCUtilityFileSystem: NSObject {
             } else {
                 return fileNameViewSize == metadata.size
             }
-        } catch {
-            print("Error: \(error)")
-        }
+        } catch { print("Error: \(error)") }
 
         return false
     }
 
+    func fileProviderStorageSize(_ ocId: String, fileNameView: String) -> UInt64 {
+
+        let fileNamePath = getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)
+        do {
+            let fileNameAttribute = try fileManager.attributesOfItem(atPath: fileNamePath)
+            let fileNameSize: UInt64 = fileNameAttribute[FileAttributeKey.size] as? UInt64 ?? 0
+            return fileNameSize
+        } catch { print("Error: \(error)") }
+
+        return 0
+    }
+
     // MARK: -
 
     @objc func getFileSize(filePath: String) -> Int64 {