|
@@ -65,7 +65,7 @@ import Alamofire
|
|
lastReachability = false
|
|
lastReachability = false
|
|
}
|
|
}
|
|
|
|
|
|
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_setTitleMain), object: nil, userInfo: nil)
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_setTitleMain)
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
@@ -179,7 +179,7 @@ import Alamofire
|
|
|
|
|
|
NCManageDatabase.sharedInstance.addMetadata(metadata)
|
|
NCManageDatabase.sharedInstance.addMetadata(metadata)
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -197,19 +197,19 @@ import Alamofire
|
|
metadata.session = NCCommunicationCommon.shared.sessionIdentifierDownload
|
|
metadata.session = NCCommunicationCommon.shared.sessionIdentifierDownload
|
|
if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
|
|
if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
-
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
+
|
|
NCCommunication.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { (request) in
|
|
NCCommunication.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { (request) in
|
|
|
|
|
|
self.downloadRequest[fileNameLocalPath] = request
|
|
self.downloadRequest[fileNameLocalPath] = request
|
|
metadata.status = Int(k_metadataStatusDownloading)
|
|
metadata.status = Int(k_metadataStatusDownloading)
|
|
if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
|
|
if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadFileStart), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":serverUrl, "account":metadata.account])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_downloadFileStart, userInfo: ["ocId":metadata.ocId, "serverUrl":serverUrl, "account":metadata.account])
|
|
|
|
|
|
}, progressHandler: { (progress) in
|
|
}, progressHandler: { (progress) in
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_progressTask), object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInDownload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_progressTask, object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInDownload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
|
|
|
|
|
|
}) { (account, etag, date, length, error, errorCode, errorDescription) in
|
|
}) { (account, etag, date, length, error, errorCode, errorDescription) in
|
|
|
|
|
|
@@ -217,7 +217,6 @@ import Alamofire
|
|
|
|
|
|
if errorCode == 0 {
|
|
if errorCode == 0 {
|
|
|
|
|
|
- metadata.date = date ?? NSDate()
|
|
|
|
metadata.etag = etag ?? ""
|
|
metadata.etag = etag ?? ""
|
|
if setFavorite { metadata.favorite = true }
|
|
if setFavorite { metadata.favorite = true }
|
|
|
|
|
|
@@ -235,7 +234,7 @@ import Alamofire
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadedFile), object: nil, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_downloadedFile, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
|
|
|
|
|
|
} else if error?.isExplicitlyCancelledError ?? false {
|
|
} else if error?.isExplicitlyCancelledError ?? false {
|
|
|
|
|
|
@@ -261,10 +260,10 @@ import Alamofire
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadedFile), object: nil, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_downloadedFile, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
|
|
}
|
|
}
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
|
|
completion(errorCode)
|
|
completion(errorCode)
|
|
}
|
|
}
|
|
@@ -282,11 +281,11 @@ import Alamofire
|
|
CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
|
|
CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
|
|
NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
|
|
NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @objc func upload(metadata: tableMetadata) {
|
|
|
|
|
|
+ @objc func upload(metadata: tableMetadata, background: Bool = true, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
|
|
|
|
|
|
var metadataForUpload: tableMetadata?
|
|
var metadataForUpload: tableMetadata?
|
|
var e2eEncrypted = false
|
|
var e2eEncrypted = false
|
|
@@ -294,7 +293,8 @@ import Alamofire
|
|
var fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
|
|
var fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
|
|
|
|
|
|
guard let account = NCManageDatabase.sharedInstance.getAccount(predicate: NSPredicate(format: "account == %@", metadata.account)) else {
|
|
guard let account = NCManageDatabase.sharedInstance.getAccount(predicate: NSPredicate(format: "account == %@", metadata.account)) else {
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"Internal error"])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"Internal error"])
|
|
|
|
+ completion(Int(k_CCErrorInternalError), "Internal error")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -316,7 +316,8 @@ import Alamofire
|
|
metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNameLocalPath)
|
|
metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNameLocalPath)
|
|
|
|
|
|
if metadata.size > Double(k_max_filesize_E2EE) {
|
|
if metadata.size > Double(k_max_filesize_E2EE) {
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"E2E Error file too big"])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"E2E Error file too big"])
|
|
|
|
+ completion(Int(k_CCErrorInternalError), "E2E Error file too big")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -324,10 +325,12 @@ import Alamofire
|
|
|
|
|
|
if e2eEncrypted {
|
|
if e2eEncrypted {
|
|
#if !EXTENSION
|
|
#if !EXTENSION
|
|
- NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account)
|
|
|
|
|
|
+ NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account, completion: completion)
|
|
#endif
|
|
#endif
|
|
|
|
+ } else if background {
|
|
|
|
+ uploadFileInBackground(metadata: metadataForUpload!, account: account, completion: completion)
|
|
} else {
|
|
} else {
|
|
- uploadFile(metadata: metadataForUpload!, account: account)
|
|
|
|
|
|
+ uploadFile(metadata: metadataForUpload!, account: account, completion: completion)
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -336,6 +339,7 @@ import Alamofire
|
|
|
|
|
|
guard let extractMetadata = extractMetadata else {
|
|
guard let extractMetadata = extractMetadata else {
|
|
NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
|
|
NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
|
|
|
|
+ completion(Int(k_CCErrorInternalError), "Internal error")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -343,7 +347,8 @@ import Alamofire
|
|
CCUtility.moveFile(atPath: fileNamePath, toPath: fileNameLocalPath)
|
|
CCUtility.moveFile(atPath: fileNamePath, toPath: fileNameLocalPath)
|
|
|
|
|
|
if e2eEncrypted && (extractMetadata.size > Double(k_max_filesize_E2EE)) {
|
|
if e2eEncrypted && (extractMetadata.size > Double(k_max_filesize_E2EE)) {
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"E2E Error file too big"])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"E2E Error file too big"])
|
|
|
|
+ completion(Int(k_CCErrorInternalError), "E2E Error file too big")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -351,16 +356,24 @@ import Alamofire
|
|
|
|
|
|
if e2eEncrypted {
|
|
if e2eEncrypted {
|
|
#if !EXTENSION
|
|
#if !EXTENSION
|
|
- NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account)
|
|
|
|
|
|
+ NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account, completion: completion)
|
|
#endif
|
|
#endif
|
|
|
|
+ } else if background {
|
|
|
|
+ self.uploadFileInBackground(metadata: metadataForUpload!, account: account, completion: completion)
|
|
} else {
|
|
} else {
|
|
- self.uploadFile(metadata: metadataForUpload!, account: account)
|
|
|
|
|
|
+ self.uploadFile(metadata: metadataForUpload!, account: account, completion: completion)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private func uploadFile(metadata: tableMetadata, account: tableAccount) {
|
|
|
|
|
|
+ //
|
|
|
|
+ private func uploadFile(metadata: tableMetadata, account: tableAccount, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
|
|
|
|
+
|
|
|
|
+ completion(0, "")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func uploadFileInBackground(metadata: tableMetadata, account: tableAccount, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
|
|
|
|
|
|
var session: URLSession?
|
|
var session: URLSession?
|
|
let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
|
|
let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
|
|
@@ -383,8 +396,12 @@ import Alamofire
|
|
CCGraphics.createNewImage(from: metadata.fileNameView, ocId: metadata.ocId, typeFile: metadata.typeFile)
|
|
CCGraphics.createNewImage(from: metadata.fileNameView, ocId: metadata.ocId, typeFile: metadata.typeFile)
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadFileStart), object: nil, userInfo: ["ocId":metadata.ocId, "task":task, "serverUrl":metadata.serverUrl, "account":metadata.account])
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadFileStart, userInfo: ["ocId":metadata.ocId, "task":task, "serverUrl":metadata.serverUrl, "account":metadata.account])
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
+
|
|
|
|
+ completion(0, "")
|
|
|
|
+ } else {
|
|
|
|
+ completion(Int(k_CCErrorInternalError), "task null")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -393,7 +410,7 @@ import Alamofire
|
|
|
|
|
|
if let metadata = NCManageDatabase.sharedInstance.getMetadataInSessionFromFileName(fileName, serverUrl: serverUrl, taskIdentifier: task.taskIdentifier) {
|
|
if let metadata = NCManageDatabase.sharedInstance.getMetadataInSessionFromFileName(fileName, serverUrl: serverUrl, taskIdentifier: task.taskIdentifier) {
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_progressTask), object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress), "totalBytes":NSNumber(value: totalBytes), "totalBytesExpected":NSNumber(value: totalBytesExpected)])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_progressTask, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress), "totalBytes":NSNumber(value: totalBytes), "totalBytesExpected":NSNumber(value: totalBytesExpected)])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -413,7 +430,7 @@ import Alamofire
|
|
CCUtility.moveFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId), toPath: CCUtility.getDirectoryProviderStorageOcId(ocId))
|
|
CCUtility.moveFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId), toPath: CCUtility.getDirectoryProviderStorageOcId(ocId))
|
|
NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
|
|
NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
|
|
|
|
|
|
- metadata.date = date ?? NSDate()
|
|
|
|
|
|
+ metadata.uploadDate = date ?? NSDate()
|
|
metadata.etag = etag ?? ""
|
|
metadata.etag = etag ?? ""
|
|
metadata.ocId = ocId!
|
|
metadata.ocId = ocId!
|
|
|
|
|
|
@@ -436,7 +453,7 @@ import Alamofire
|
|
}
|
|
}
|
|
|
|
|
|
#if !EXTENSION
|
|
#if !EXTENSION
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":""])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":""])
|
|
#endif
|
|
#endif
|
|
|
|
|
|
} else if errorCode == NSURLErrorCancelled {
|
|
} else if errorCode == NSURLErrorCancelled {
|
|
@@ -449,8 +466,8 @@ import Alamofire
|
|
metadata.status = Int(k_metadataStatusInUpload)
|
|
metadata.status = Int(k_metadataStatusInUpload)
|
|
|
|
|
|
if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
|
|
if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
|
|
- NCNetworking.shared.upload(metadata: metadata)
|
|
|
|
-
|
|
|
|
|
|
+ NCNetworking.shared.upload(metadata: metadata) { (_, _) in }
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
|
|
|
|
CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
|
|
CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
|
|
@@ -480,12 +497,12 @@ import Alamofire
|
|
metadata.sessionTaskIdentifier = 0
|
|
metadata.sessionTaskIdentifier = 0
|
|
metadata.status = Int(k_metadataStatusUploadError)
|
|
metadata.status = Int(k_metadataStatusUploadError)
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":errorDescription])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":errorDescription])
|
|
|
|
|
|
if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
|
|
if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
|
|
}
|
|
}
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -506,7 +523,7 @@ import Alamofire
|
|
metadata.status = Int(k_metadataStatusNormal)
|
|
metadata.status = Int(k_metadataStatusNormal)
|
|
NCManageDatabase.sharedInstance.addMetadata(metadata)
|
|
NCManageDatabase.sharedInstance.addMetadata(metadata)
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -520,7 +537,7 @@ import Alamofire
|
|
CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
|
|
CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
|
|
NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
|
|
NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -623,7 +640,7 @@ import Alamofire
|
|
NCManageDatabase.sharedInstance.addMetadatas(metadatasInUpload!)
|
|
NCManageDatabase.sharedInstance.addMetadatas(metadatasInUpload!)
|
|
}
|
|
}
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":serverUrl])
|
|
|
|
|
|
completion(account, metadataFolderInserted, metadatasInserted, errorCode, "")
|
|
completion(account, metadataFolderInserted, metadatasInserted, errorCode, "")
|
|
}
|
|
}
|
|
@@ -703,7 +720,7 @@ import Alamofire
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":serverUrl])
|
|
|
|
|
|
} else if errorCode == 405 && overwrite {
|
|
} else if errorCode == 405 && overwrite {
|
|
self.NotificationPost(name: k_notificationCenter_createFolder, userInfo: ["fileName": fileName, "serverUrl": serverUrl, "errorCode": 0], errorDescription: "", completion: completion)
|
|
self.NotificationPost(name: k_notificationCenter_createFolder, userInfo: ["fileName": fileName, "serverUrl": serverUrl, "errorCode": 0], errorDescription: "", completion: completion)
|
|
@@ -775,7 +792,7 @@ import Alamofire
|
|
NCManageDatabase.sharedInstance.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
|
|
NCManageDatabase.sharedInstance.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
|
|
}
|
|
}
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
|
|
}
|
|
}
|
|
|
|
|
|
self.NotificationPost(name: k_notificationCenter_deleteFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
self.NotificationPost(name: k_notificationCenter_deleteFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
@@ -809,7 +826,7 @@ import Alamofire
|
|
if errorCode == 0 && metadata.account == account {
|
|
if errorCode == 0 && metadata.account == account {
|
|
NCManageDatabase.sharedInstance.setMetadataFavorite(ocId: metadata.ocId, favorite: favorite)
|
|
NCManageDatabase.sharedInstance.setMetadataFavorite(ocId: metadata.ocId, favorite: favorite)
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
}
|
|
}
|
|
|
|
|
|
self.NotificationPost(name: k_notificationCenter_favoriteFile, userInfo: ["metadata": metadata, "favorite": favorite, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
self.NotificationPost(name: k_notificationCenter_favoriteFile, userInfo: ["metadata": metadata, "favorite": favorite, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
@@ -904,7 +921,7 @@ import Alamofire
|
|
} catch { }
|
|
} catch { }
|
|
}
|
|
}
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
|
|
}
|
|
}
|
|
|
|
|
|
self.NotificationPost(name: k_notificationCenter_renameFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
self.NotificationPost(name: k_notificationCenter_renameFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
@@ -953,8 +970,8 @@ import Alamofire
|
|
metadataNew = metadataMove
|
|
metadataNew = metadataMove
|
|
}
|
|
}
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrlTo])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":serverUrlTo])
|
|
}
|
|
}
|
|
|
|
|
|
self.NotificationPost(name: k_notificationCenter_moveFile, userInfo: ["metadata": metadata, "metadataNew": metadataNew, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
self.NotificationPost(name: k_notificationCenter_moveFile, userInfo: ["metadata": metadata, "metadataNew": metadataNew, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
@@ -991,7 +1008,7 @@ import Alamofire
|
|
|
|
|
|
NCCommunication.shared.copyFileOrFolder(serverUrlFileNameSource: serverUrlFileNameSource, serverUrlFileNameDestination: serverUrlFileNameDestination, overwrite: overwrite) { (account, errorCode, errorDescription) in
|
|
NCCommunication.shared.copyFileOrFolder(serverUrlFileNameSource: serverUrlFileNameSource, serverUrlFileNameDestination: serverUrlFileNameDestination, overwrite: overwrite) { (account, errorCode, errorDescription) in
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrlTo])
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":serverUrlTo])
|
|
|
|
|
|
self.NotificationPost(name: k_notificationCenter_copyFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
self.NotificationPost(name: k_notificationCenter_copyFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
}
|
|
}
|
|
@@ -1006,7 +1023,7 @@ import Alamofire
|
|
if errorDescription == nil { userInfo["errorDescription"] = "" }
|
|
if errorDescription == nil { userInfo["errorDescription"] = "" }
|
|
else { userInfo["errorDescription"] = NSLocalizedString(errorDescription as! String, comment: "") }
|
|
else { userInfo["errorDescription"] = NSLocalizedString(errorDescription as! String, comment: "") }
|
|
|
|
|
|
- NotificationCenter.default.post(name: Notification.Name.init(rawValue: name), object: nil, userInfo: userInfo)
|
|
|
|
|
|
+ NotificationCenter.default.postOnMainThread(name: name, userInfo: userInfo)
|
|
|
|
|
|
completion(userInfo["errorCode"] as! Int, userInfo["errorDescription"] as! String)
|
|
completion(userInfo["errorCode"] as! Int, userInfo["errorDescription"] as! String)
|
|
}
|
|
}
|