marinofaggiana 4 years ago
parent
commit
16a513700a
2 changed files with 8 additions and 4 deletions
  1. 6 4
      iOSClient/AppDelegate.m
  2. 2 0
      iOSClient/Utility/NCUtility.swift

+ 6 - 4
iOSClient/AppDelegate.m

@@ -724,11 +724,13 @@
 
 - (void)uploadedFile:(NSNotification *)notification
 {
-    NSArray *metadatasSessionUpload = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND session CONTAINS[cd] %@", self.activeAccount, @"upload"] sorted:nil ascending:true];
-    if (metadatasSessionUpload.count == 0) {
-        
+    NSDictionary *userInfo = notification.userInfo;
+    tableMetadata *metadata = userInfo[@"metadata"];
+    NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
+   
+    if (errorCode == 0) {
         // verify delete Asset Local Identifiers in auto upload
-        [[NCUtility sharedInstance] deleteAssetLocalIdentifiersWithAccount:self.activeAccount sessionSelector:selectorUploadAutoUpload];
+        [[NCUtility sharedInstance] deleteAssetLocalIdentifiersWithAccount:metadata.account sessionSelector:selectorUploadAutoUpload];
     }
 }
 

+ 2 - 0
iOSClient/Utility/NCUtility.swift

@@ -536,6 +536,8 @@ class NCUtility: NSObject {
     @objc func deleteAssetLocalIdentifiers(account: String, sessionSelector: String) {
         
         if UIApplication.shared.applicationState != .active { return }
+        let metadatasSessionUpload = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND session CONTAINS[cd] %@", account, "upload"), sorted: nil, ascending: true)
+        if metadatasSessionUpload == nil || metadatasSessionUpload!.count > 0 { return }
         let localIdentifiers = NCManageDatabase.sharedInstance.getAssetLocalIdentifiersUploaded(account: account, sessionSelector: sessionSelector)
         if localIdentifiers.count == 0 { return }
         let assets = PHAsset.fetchAssets(withLocalIdentifiers: localIdentifiers, options: nil)