marinofaggiana 4 years ago
parent
commit
49e2dc9d0c

+ 1 - 3
iOSClient/Networking/NCNetworking.swift

@@ -240,9 +240,7 @@ import Alamofire
                     NCEndToEndEncryption.sharedManager()?.decryptFileName(metadata.fileName, fileNameView: metadata.fileNameView, ocId: metadata.ocId, key: result.key, initializationVector: result.initializationVector, authenticationTag: result.authenticationTag)
                 }
                 #endif
-                
-               
-                
+                                
                 NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadedFile), object: nil, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
                 
             } else if errorCode == Int(CFNetworkErrors.cfurlErrorCancelled.rawValue) || errorCode == 200 {

+ 5 - 5
iOSClient/Networking/NCNetworkingE2EE.swift

@@ -249,21 +249,21 @@ import CFNetwork
                 
                     NCNetworking.shared.uploadRequest[fileNameLocalPath] = nil
                     
-                    if (errorCode == 0 && date != nil && etag != nil && ocId != nil) {
+                    if (errorCode == 0 && ocId != nil) {
                             
                         CCUtility.moveFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId), toPath:  CCUtility.getDirectoryProviderStorageOcId(ocId))
                         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                             
-                        metadata.date = date!
-                        metadata.etag = etag!
+                        metadata.date = date ?? NSDate()
+                        metadata.etag = etag ?? ""
                         metadata.ocId = ocId!
                         
                         metadata.session = ""
                         metadata.sessionError = ""
                         metadata.status = Int(k_metadataStatusNormal)
-                                                    
-                        if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
+                                           
                         NCManageDatabase.sharedInstance.addLocalFile(metadata: metadata)
+                        if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
                         
                         CCGraphics.createNewImage(from: metadata.fileNameView, ocId: metadata.ocId, filterGrayScale: false, typeFile: metadata.typeFile, writeImage: true)