diff options
author | Marino Faggiana <marino@marinofaggiana.com> | 2022-11-04 20:03:04 +0300 |
---|---|---|
committer | Marino Faggiana <marino@marinofaggiana.com> | 2022-11-04 20:03:04 +0300 |
commit | d7471ca3ece59cb976ed816e2febdca37b982773 (patch) | |
tree | 78a76f296150ce83bf90d6327be4b023e33efafc | |
parent | 0a6b49dc9f660a33603f081128ae4145163a05c4 (diff) |
fix code
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
-rw-r--r-- | iOSClient/Networking/NCNetworkingProcessUpload.swift | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/iOSClient/Networking/NCNetworkingProcessUpload.swift b/iOSClient/Networking/NCNetworkingProcessUpload.swift index c8468e8ee..f0883268f 100644 --- a/iOSClient/Networking/NCNetworkingProcessUpload.swift +++ b/iOSClient/Networking/NCNetworkingProcessUpload.swift @@ -90,6 +90,8 @@ class NCNetworkingProcessUpload: NSObject { if appDelegate.account.isEmpty || pauseProcess { return completition(0) + } else { + pauseProcess = true } let applicationState = UIApplication.shared.applicationState @@ -179,7 +181,11 @@ class NCNetworkingProcessUpload: NSObject { // verify delete Asset Local Identifiers in auto upload (DELETE Photos album) if applicationState == .active && metadatas.isEmpty && !self.appDelegate.isPasscodePresented() { - self.deleteAssetLocalIdentifiers() + self.deleteAssetLocalIdentifiers { + self.pauseProcess = false + } + } else { + self.pauseProcess = false } } @@ -188,22 +194,21 @@ class NCNetworkingProcessUpload: NSObject { } } - private func deleteAssetLocalIdentifiers() { + private func deleteAssetLocalIdentifiers(completition: @escaping () -> Void) { let metadatasSessionUpload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND session CONTAINS[cd] %@", appDelegate.account, "upload")) - if !metadatasSessionUpload.isEmpty { return } + if !metadatasSessionUpload.isEmpty { return completition() } let localIdentifiers = NCManageDatabase.shared.getAssetLocalIdentifiersUploaded(account: appDelegate.account) - if localIdentifiers.isEmpty { return } + if localIdentifiers.isEmpty { return completition() } let assets = PHAsset.fetchAssets(withLocalIdentifiers: localIdentifiers, options: nil) - self.pauseProcess = true PHPhotoLibrary.shared().performChanges({ PHAssetChangeRequest.deleteAssets(assets as NSFastEnumeration) }, completionHandler: { _, _ in NCManageDatabase.shared.clearAssetLocalIdentifiers(localIdentifiers, account: self.appDelegate.account) - self.pauseProcess = false + completition() }) } |