|
@@ -307,7 +307,7 @@ import Photos
|
|
|
request.cancel()
|
|
|
} else if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
NCManageDatabase.shared.setMetadataSession(ocId: ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal)
|
|
|
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadCancelFile, userInfo: ["ocId": metadata.ocId])
|
|
|
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -329,7 +329,7 @@ import Photos
|
|
|
self.downloadRequest[fileNameLocalPath] = request
|
|
|
|
|
|
NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, status: NCGlobal.shared.metadataStatusDownloading)
|
|
|
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadStartFile, userInfo: ["ocId":metadata.ocId])
|
|
|
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadStartFile, userInfo: ["ocId":metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
|
|
|
|
|
|
}, taskHandler: { (_) in
|
|
|
|
|
@@ -341,10 +341,13 @@ import Photos
|
|
|
progressHandler(progress)
|
|
|
|
|
|
}) { (account, etag, date, _, allHeaderFields, error, errorCode, errorDescription) in
|
|
|
-
|
|
|
+
|
|
|
+ self.downloadRequest[fileNameLocalPath] = nil
|
|
|
+
|
|
|
if error?.isExplicitlyCancelledError ?? false {
|
|
|
|
|
|
NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: selector, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal)
|
|
|
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
|
|
|
|
|
|
} else if errorCode == 0 {
|
|
|
|
|
@@ -352,11 +355,11 @@ import Photos
|
|
|
NCManageDatabase.shared.addLocalFile(metadata: metadata)
|
|
|
#if !EXTENSION
|
|
|
if let result = NCManageDatabase.shared.getE2eEncryption(predicate: NSPredicate(format: "fileNameIdentifier == %@ AND serverUrl == %@", metadata.fileName, metadata.serverUrl)) {
|
|
|
-
|
|
|
NCEndToEndEncryption.sharedManager()?.decryptFileName(metadata.fileName, fileNameView: metadata.fileNameView, ocId: metadata.ocId, key: result.key, initializationVector: result.initializationVector, authenticationTag: result.authenticationTag)
|
|
|
}
|
|
|
CCUtility.setExif(metadata) { _, _, _, _, _ in }
|
|
|
#endif
|
|
|
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "selector": selector, "errorCode": 0, "errorDescription": ""])
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -366,17 +369,10 @@ import Photos
|
|
|
NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: metadata.account, errorCode: errorCode, errorDescription: errorDescription)
|
|
|
}
|
|
|
#endif
|
|
|
+ NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "selector": selector, "errorCode": errorCode, "errorDescription": errorDescription])
|
|
|
}
|
|
|
|
|
|
- self.downloadRequest[fileNameLocalPath] = nil
|
|
|
- if error?.isExplicitlyCancelledError ?? false {
|
|
|
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadCancelFile, userInfo: ["ocId": metadata.ocId])
|
|
|
- } else {
|
|
|
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": selector, "errorCode": errorCode, "errorDescription": errorDescription])
|
|
|
- }
|
|
|
- DispatchQueue.main.async {
|
|
|
- completion(errorCode)
|
|
|
- }
|
|
|
+ DispatchQueue.main.async { completion(errorCode) }
|
|
|
}
|
|
|
}
|
|
|
|