diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index 3611c98f19..58adb19485 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -257,9 +257,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Create share accounts \(error.localizedDescription)") } - NCOperationQueue.shared.cancelAllQueue() - NCNetworking.shared.cancelAllDownloadTransfer() - NextcloudKit.shared.sessionManager.cancelAllRequests() + NCNetworking.shared.cancelSessions(inBackground: false) presentPasscode { } @@ -269,7 +267,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // L'applicazione terminerà func applicationWillTerminate(_ application: UIApplication) { - NCNetworking.shared.cancelAllDownloadTransfer() + NCNetworking.shared.cancelSessions(inBackground: false) if UIApplication.shared.backgroundRefreshStatus == .available { @@ -560,8 +558,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD guard let tableAccount = NCManageDatabase.shared.setAccountActive(account) else { return } - NCOperationQueue.shared.cancelAllQueue() - NCNetworking.shared.cancelAllTask() + NCNetworking.shared.cancelSessions(inBackground: false) self.account = tableAccount.account self.urlBase = tableAccount.urlBase diff --git a/iOSClient/Color/NCColorPicker.swift b/iOSClient/Color/NCColorPicker.swift index ace49d09a8..76551bdafe 100644 --- a/iOSClient/Color/NCColorPicker.swift +++ b/iOSClient/Color/NCColorPicker.swift @@ -199,7 +199,7 @@ class NCColorPicker: UIViewController { let serverUrl = metadata.serverUrl + "/" + metadata.fileName if NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, colorFolder: hexColor, account: metadata.account) != nil { self.dismiss(animated: true) - NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": metadata.serverUrl]) + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource) } } self.dismiss(animated: true) diff --git a/iOSClient/Data/NCManageDatabase+Metadata.swift b/iOSClient/Data/NCManageDatabase+Metadata.swift index c4413a8a6e..64871afe9f 100644 --- a/iOSClient/Data/NCManageDatabase+Metadata.swift +++ b/iOSClient/Data/NCManageDatabase+Metadata.swift @@ -631,28 +631,29 @@ extension NCManageDatabase { do { let realm = try Realm() try realm.write { - let result = realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first - if let newFileName = newFileName { - result?.fileName = newFileName - result?.fileNameView = newFileName - } - if let session = session { - result?.session = session - } - if let sessionError = sessionError { - result?.sessionError = sessionError - } - if let sessionSelector = sessionSelector { - result?.sessionSelector = sessionSelector - } - if let sessionTaskIdentifier = sessionTaskIdentifier { - result?.sessionTaskIdentifier = sessionTaskIdentifier - } - if let status = status { - result?.status = status - } - if let etag = etag { - result?.etag = etag + if let result = realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first { + if let newFileName = newFileName { + result.fileName = newFileName + result.fileNameView = newFileName + } + if let session = session { + result.session = session + } + if let sessionError = sessionError { + result.sessionError = sessionError + } + if let sessionSelector = sessionSelector { + result.sessionSelector = sessionSelector + } + if let sessionTaskIdentifier = sessionTaskIdentifier { + result.sessionTaskIdentifier = sessionTaskIdentifier + } + if let status = status { + result.status = status + } + if let etag = etag { + result.etag = etag + } } } } catch let error { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 54b9385b5b..f403f63916 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -801,7 +801,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS if namedButtonMore == NCGlobal.shared.buttonMoreMore || namedButtonMore == NCGlobal.shared.buttonMoreLock { toggleMenu(metadata: metadata, indexPath: indexPath, imageIcon: image) } else if namedButtonMore == NCGlobal.shared.buttonMoreStop { - NCNetworking.shared.cancelTransferMetadata(metadata) { } + Task { + await NCNetworking.shared.cancel(metadata: metadata) + } } } @@ -826,7 +828,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS func tapButtonTransfer(_ sender: Any) { if let ocId = NCNetworking.shared.transferInForegorund?.ocId, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) { - NCNetworking.shared.cancelTransferMetadata(metadata) { } + Task { + await NCNetworking.shared.cancel(metadata: metadata) + } } } diff --git a/iOSClient/Menu/NCSortMenu.swift b/iOSClient/Menu/NCSortMenu.swift index 14f0538c08..df3941aff6 100644 --- a/iOSClient/Menu/NCSortMenu.swift +++ b/iOSClient/Menu/NCSortMenu.swift @@ -144,6 +144,6 @@ class NCSortMenu: NSObject { self.sortButton?.setTitle(NSLocalizedString(layoutForView.titleButtonHeader, comment: ""), for: .normal) NCManageDatabase.shared.setLayoutForView(layoutForView: layoutForView) - NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": self.serverUrl]) + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource) } } diff --git a/iOSClient/NCGlobal.swift b/iOSClient/NCGlobal.swift index 6857ce2c1e..2500547e15 100644 --- a/iOSClient/NCGlobal.swift +++ b/iOSClient/NCGlobal.swift @@ -208,9 +208,10 @@ class NCGlobal: NSObject { @objc let errorUnauthorized401: Int = 401 @objc let errorForbidden: Int = 403 @objc let errorResourceNotFound: Int = 404 - @objc let errordMethodNotSupported: Int = 405 + @objc let errorMethodNotSupported: Int = 405 @objc let errorConflict: Int = 409 @objc let errorPreconditionFailed: Int = 412 + @objc let errorQuota: Int = 507 @objc let errorUnauthorized997: Int = 997 @objc let errorConnectionLost: Int = -1005 @objc let errorNetworkNotAvailable: Int = -1009 @@ -348,8 +349,8 @@ class NCGlobal: NSObject { let notificationCenterUpdateBadgeNumber = "updateBadgeNumber" // userInfo: counter let notificationCenterReloadAvatar = "reloadAvatar" - @objc let notificationCenterReloadDataSource = "reloadDataSource" // userInfo: serverUrl? - let notificationCenterReloadDataSourceNetwork = "reloadDataSourceNetwork" // userInfo: serverUrl? + @objc let notificationCenterReloadDataSource = "reloadDataSource" + let notificationCenterReloadDataSourceNetwork = "reloadDataSourceNetwork" let notificationCenterReloadDataSourceNetworkForced = "reloadDataSourceNetworkForced" let notificationCenterChangeStatusFolderE2EE = "changeStatusFolderE2EE" // userInfo: serverUrl diff --git a/iOSClient/Networking/NCNetworking.swift b/iOSClient/Networking/NCNetworking.swift index 3e13b288ef..714d9beeb8 100644 --- a/iOSClient/Networking/NCNetworking.swift +++ b/iOSClient/Networking/NCNetworking.swift @@ -284,56 +284,8 @@ class NCNetworking: NSObject, NKCommonDelegate { } } - // MARK: - Utility - - func cancelTaskWithUrl(_ url: URL) { - NextcloudKit.shared.getSessionManager().getAllTasks { tasks in - tasks.filter { $0.state == .running }.filter { $0.originalRequest?.url == url }.first?.cancel() - } - } - - func cancelAllTask() { - NextcloudKit.shared.getSessionManager().getAllTasks { tasks in - for task in tasks { - task.cancel() - } - } - } - - func isInTaskUploadBackground(fileName: String, completion: @escaping (_ exists: Bool) -> Void) { - - let sessions: [URLSession] = [NCNetworking.shared.sessionManagerBackground, NCNetworking.shared.sessionManagerBackgroundWWan] - - for session in sessions { - session.getAllTasks(completionHandler: { tasks in - for task in tasks { - let url = task.originalRequest?.url - let urlFileName = url?.lastPathComponent - if urlFileName == fileName { - completion(true) - } - } - if session == sessions.last { - completion(false) - } - }) - } - } - // MARK: - Download - func cancelDownload(ocId: String, serverUrl: String, fileName: String) { - - guard let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName) else { return } - - if let request = downloadRequest[fileNameLocalPath] { - 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, "serverUrl": metadata.serverUrl, "account": metadata.account]) - } - } - func download(metadata: tableMetadata, selector: String, notificationCenterProgressTask: Bool = true, requestHandler: @escaping (_ request: DownloadRequest) -> Void = { _ in }, progressHandler: @escaping (_ progress: Progress) -> Void = { _ in }, @@ -768,113 +720,119 @@ class NCNetworking: NSObject, NKCommonDelegate { }) } - // MARK: - Transfer (Download Upload) + // MARK: - Cancel (Download Upload) - func cancelTransferMetadata(_ metadata: tableMetadata, completion: @escaping () -> Void) { + // sessionIdentifierDownload: String = "com.nextcloud.nextcloudkit.session.download" + // sessionIdentifierUpload: String = "com.nextcloud.nextcloudkit.session.upload" - let metadata = tableMetadata.init(value: metadata) + // sessionIdentifierBackground: String = "com.nextcloud.session.upload.background" + // sessionIdentifierBackgroundWWan: String = "com.nextcloud.session.upload.backgroundWWan" + // sessionIdentifierBackgroundExtension: String = "com.nextcloud.session.upload.extension" - if metadata.session.count == 0 { - NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - return completion() + func cancelSessions(inBackground: Bool) { + Task { + await cancel(inBackground: inBackground) } + } - if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload { + func cancel(inBackground: Bool) async { - NCNetworking.shared.cancelDownload(ocId: metadata.ocId, serverUrl: metadata.serverUrl, fileName: metadata.fileName) - return completion() - } +#if !EXTENSION + NCOperationQueue.shared.downloadCancelAll() +#endif - if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload || metadata.chunk > 0 { + NextcloudKit.shared.sessionManager.cancelAllRequests() - CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) - if let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), - let request = uploadRequest[fileNameLocalPath] { - request.cancel() - } - NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account]) + downloadRequest.removeAll() + uploadRequest.removeAll() - return completion() - } + let metadatasDownload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status < 0")) + let metadatasUpload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status > 0 AND session == %@", NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload)) + let metadatasUploadBackground = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status > 0 AND (session == %@ || session == %@)", NCNetworking.shared.sessionIdentifierBackground, NCNetworking.shared.sessionIdentifierBackgroundWWan)) - var session: URLSession? - if metadata.session == NCNetworking.shared.sessionIdentifierBackground { - session = NCNetworking.shared.sessionManagerBackground - } else if metadata.session == NCNetworking.shared.sessionIdentifierBackgroundWWan { - session = NCNetworking.shared.sessionManagerBackgroundWWan + // DOWNLOAD + for metadata in metadatasDownload { + CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal) } - if session == nil { + // UPLOAD + for metadata in metadatasUpload { + CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account]) - return completion() } - session?.getTasksWithCompletionHandler { _, uploadTasks, _ in + guard inBackground else { return } - var cancel = false - if metadata.session.count > 0 && metadata.session.contains("upload") { - for task in uploadTasks { - if task.taskIdentifier == metadata.sessionTaskIdentifier { - task.cancel() - cancel = true - } - } - if cancel == false { - do { - try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) - } catch { } - NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account]) - } - } - completion() + // BACKGROUND + for metadata in metadatasUploadBackground { + CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) + NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) } + + let tasksBackground = await NCNetworking.shared.sessionManagerBackground.tasks + for task in tasksBackground.1 { // ([URLSessionDataTask], [URLSessionUploadTask], [URLSessionDownloadTask]) + task.cancel() + } + let tasksBackgroundWWan = await NCNetworking.shared.sessionManagerBackgroundWWan.tasks + for task in tasksBackgroundWWan.1 { // ([URLSessionDataTask], [URLSessionUploadTask], [URLSessionDownloadTask]) + task.cancel() + } + + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource) } - func cancelAllTransfer(account: String, completion: @escaping () -> Void) { + func cancel(metadata: tableMetadata) async { - NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "status == %d OR status == %d", account, NCGlobal.shared.metadataStatusWaitUpload, NCGlobal.shared.metadataStatusUploadError)) + let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)! + CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId)) - let metadatas = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status != %d", NCGlobal.shared.metadataStatusNormal)) + // No session found + if metadata.session.isEmpty { + uploadRequest.removeValue(forKey: fileNameLocalPath) + downloadRequest.removeValue(forKey: fileNameLocalPath) + NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource) + return + } - var counter = 0 - for metadata in metadatas { - counter += 1 - if metadata.status == NCGlobal.shared.metadataStatusWaitDownload || metadata.status == NCGlobal.shared.metadataStatusDownloadError { + // DOWNLOAD + if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload { + if let request = downloadRequest[fileNameLocalPath] { + request.cancel() + } else if let metadata = NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) { NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal) + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account]) } - if metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusUploading { - self.cancelTransferMetadata(metadata) { - if counter == metadatas.count { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - completion() - } - } - } - } + return } -#if !EXTENSION - NCOperationQueue.shared.downloadCancelAll() -#endif - } - - func cancelAllDownloadTransfer() { - - let metadatas = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status != %d", NCGlobal.shared.metadataStatusNormal)) - for metadata in metadatas { - if metadata.status == NCGlobal.shared.metadataStatusWaitDownload || metadata.status == NCGlobal.shared.metadataStatusDownloadError { - NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal) - } - if metadata.status == NCGlobal.shared.metadataStatusDownloading && metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload { - cancelDownload(ocId: metadata.ocId, serverUrl: metadata.serverUrl, fileName: metadata.fileName) + // UPLOAD FOREGROUND + if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload { + if let request = uploadRequest[fileNameLocalPath] { + request.cancel() + uploadRequest.removeValue(forKey: fileNameLocalPath) } + NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account]) + return } -#if !EXTENSION - NCOperationQueue.shared.downloadCancelAll() -#endif + // UPLOAD BACKGROUND + var session: URLSession? + if metadata.session == NCNetworking.shared.sessionIdentifierBackground { + session = NCNetworking.shared.sessionManagerBackground + } else if metadata.session == NCNetworking.shared.sessionIdentifierBackgroundWWan { + session = NCNetworking.shared.sessionManagerBackgroundWWan + } + if let tasks = await session?.tasks { + for task in tasks.1 { // ([URLSessionDataTask], [URLSessionUploadTask], [URLSessionDownloadTask]) + if task.taskIdentifier == metadata.sessionTaskIdentifier { + task.cancel() + NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account]) + } + } + } } // MARK: - WebDav Read file, folder @@ -1176,7 +1134,7 @@ class NCNetworking: NSObject, NKCommonDelegate { NextcloudKit.shared.createFolder(serverUrlFileName: fileNameFolderUrl) { account, _, _, error in guard error == .success else { - if error.errorCode == NCGlobal.shared.errordMethodNotSupported && overwrite { + if error.errorCode == NCGlobal.shared.errorMethodNotSupported && overwrite { completion(NKError()) } else { completion(error) diff --git a/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift b/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift index 1dfc375ec3..a3d0bb4c71 100644 --- a/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift +++ b/iOSClient/Networking/NCNetworkingCheckRemoteUser.swift @@ -27,28 +27,16 @@ class NCNetworkingCheckRemoteUser { func checkRemoteUser(account: String, error: NKError) { - guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) else { - return - } - - // remove all process ---- - - NCNetworking.shared.cancelAllTransfer(account: account) { } - NCOperationQueue.shared.cancelAllQueue() - NCNetworking.shared.cancelAllTask() + guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)), + let token = CCUtility.getPassword(account), !token.isEmpty, + let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } - // ----------------------- + NCNetworking.shared.cancelSessions(inBackground: true) if NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion17 { - let token = CCUtility.getPassword(account)! - if token.isEmpty { - return - } - NextcloudKit.shared.getRemoteWipeStatus(serverUrl: tableAccount.urlBase, token: token) { account, wipe, _, error in - let appDelegate = UIApplication.shared.delegate as! AppDelegate if wipe { appDelegate.deleteAccount(account, wipe: true) @@ -58,7 +46,7 @@ class NCNetworkingCheckRemoteUser { } else { - if UIApplication.shared.applicationState == .active && NextcloudKit.shared.isNetworkReachable() && !CCUtility.getPassword(account).isEmpty { + if UIApplication.shared.applicationState == .active && NextcloudKit.shared.isNetworkReachable() { let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase) let error = NKError(errorCode: error.errorCode, errorDescription: description) NCContentPresenter.shared.showError(error: error, priority: .max) @@ -68,7 +56,7 @@ class NCNetworkingCheckRemoteUser { } } - } else if CCUtility.getPassword(account) != "" { + } else { if UIApplication.shared.applicationState == .active && NextcloudKit.shared.isNetworkReachable() { let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase) diff --git a/iOSClient/Networking/NCNetworkingProcessUpload.swift b/iOSClient/Networking/NCNetworkingProcessUpload.swift index f06b2464e0..0843f2475c 100644 --- a/iOSClient/Networking/NCNetworkingProcessUpload.swift +++ b/iOSClient/Networking/NCNetworkingProcessUpload.swift @@ -190,7 +190,16 @@ class NCNetworkingProcessUpload: NSObject { if counterUpload == 0 { let metadatas = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND status == %d", self.appDelegate.account, NCGlobal.shared.metadataStatusUploadError)) for metadata in metadatas { - NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: NCNetworking.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload) + // Verify QUOTA + if metadata.sessionError.contains("\(NCGlobal.shared.errorQuota)") { + NextcloudKit.shared.getUserProfile { account, userProfile, _, error in + if error == .success, let userProfile, userProfile.quotaFree > 0, userProfile.quotaFree > metadata.size { + NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: NCNetworking.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload) + } + } + } else { + NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: NCNetworking.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload) + } } // verify delete Asset Local Identifiers in auto upload (DELETE Photos album) diff --git a/iOSClient/Scan document/NCScan.storyboard b/iOSClient/Scan document/NCScan.storyboard index 7c7dcb875d..b81950d2f4 100755 --- a/iOSClient/Scan document/NCScan.storyboard +++ b/iOSClient/Scan document/NCScan.storyboard @@ -1,9 +1,9 @@ - + - + @@ -17,7 +17,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -149,7 +149,7 @@