marinofaggiana 4 years ago
parent
commit
77ed798fef
2 changed files with 13 additions and 14 deletions
  1. 3 3
      Cartfile.resolved
  2. 10 11
      File Provider Extension/FileProviderExtension+Thumbnail.swift

+ 3 - 3
Cartfile.resolved

@@ -8,18 +8,18 @@ github "SwiftyJSON/SwiftyJSON" "5.0.0"
 github "WeTransfer/WeScan" "1.2.0"
 github "WenchaoD/FSCalendar" "2.8.0"
 github "dzenbot/DZNEmptyDataSet" "v1.8.1"
-github "getsentry/sentry-cocoa" "5.1.7"
+github "getsentry/sentry-cocoa" "5.1.8"
 github "huri000/QuickLayout" "3.0.0"
 github "huri000/SwiftEntryKit" "1.2.3"
 github "ivanbruel/MarkdownKit" "1.6"
 github "jdg/MBProgressHUD" "1.1.0"
 github "kishikawakatsumi/UICKeyChainStore" "v2.1.2"
 github "krzyzanowskim/OpenSSL" "1.0.218"
-github "malcommac/SwiftRichString" "3.7.1"
+github "malcommac/SwiftRichString" "3.7.2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.7"
 github "marinofaggiana/XLForm" "eb9381ad8129f60402bf412250fb31b95a628a08"
-github "nextcloud/ios-communication-library" "7b824aedece56fcc3ca85d493387e7b9a88ed744"
+github "nextcloud/ios-communication-library" "572d391e2e5b6a8ae59e43f1d632c3d1411eabc3"
 github "realm/realm-cocoa" "v5.2.0"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.5"

+ 10 - 11
File Provider Extension/FileProviderExtension+Thumbnail.swift

@@ -43,24 +43,23 @@ extension FileProviderExtension {
             if (metadata.hasPreview) {
                 
                 let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: fileProviderData.sharedInstance.accountUrl)!
-                let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)!
+                //let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)!
                 let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!
                     
-                NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNamePreviewLocalPath: fileNamePreviewLocalPath , widthPreview: Int(k_sizePreview), heightPreview: Int(k_sizePreview), fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: Int(k_sizeIcon)) { (account, imagePreview, imageIcon,  errorCode, errorDescription) in
-                    if errorCode == 0 && imageIcon != nil {
-                        if let data = imageIcon!.pngData() {
-                            perThumbnailCompletionHandler(itemIdentifier, data, nil)
-                        } else {
-                            perThumbnailCompletionHandler(itemIdentifier, nil, NSFileProviderError(.serverUnreachable))
-                        }
+                NCCommunication.shared.getPreview(fileNamePath: fileNamePath, widthPreview: Int(k_sizeIcon), heightPreview: Int(k_sizeIcon)) { (account, data, errorCode, errorDescription) in
+                    if errorCode == 0 && data != nil {
+                        do {
+                            try data!.write(to: URL.init(fileURLWithPath: fileNameIconLocalPath), options: .atomic)
+                        } catch { }
+                        perThumbnailCompletionHandler(itemIdentifier, data, nil)
                     } else {
                         perThumbnailCompletionHandler(itemIdentifier, nil, NSFileProviderError(.serverUnreachable))
                     }
-                    
                     counterProgress += 1
-                    if (counterProgress == progress.totalUnitCount) { completionHandler(nil) }
+                    if (counterProgress == progress.totalUnitCount) {
+                        completionHandler(nil)
+                    }
                 }
-               
             } else {
                 
                 counterProgress += 1