marinofaggiana 4 years ago
parent
commit
3e55dcabe8
2 changed files with 13 additions and 1 deletions
  1. 12 1
      iOSClient/AppDelegate.m
  2. 1 0
      iOSClient/Utility/NCUtility.swift

+ 12 - 1
iOSClient/AppDelegate.m

@@ -185,7 +185,8 @@
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteFile:) name:k_notificationCenter_deleteFile object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moveFile:) name:k_notificationCenter_moveFile object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(copyFile:) name:k_notificationCenter_copyFile object:nil];
-
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadedFile:) name:k_notificationCenter_uploadedFile object:nil];
+    
     return YES;
 }
 
@@ -721,6 +722,16 @@
     }
 }
 
+- (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) {
+        
+        // verify delete Asset Local Identifiers in auto upload
+        [[NCUtility sharedInstance] deleteAssetLocalIdentifiersWithAccount:self.activeAccount sessionSelector:selectorUploadAutoUpload];
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Quick Actions - ShotcutItem =====
 #pragma --------------------------------------------------------------------------------------------

+ 1 - 0
iOSClient/Utility/NCUtility.swift

@@ -535,6 +535,7 @@ class NCUtility: NSObject {
     
     @objc func deleteAssetLocalIdentifiers(account: String, sessionSelector: String) {
         
+        if UIApplication.shared.applicationState != .active { return }
         let localIdentifiers = NCManageDatabase.sharedInstance.getAssetLocalIdentifiersUploaded(account: account, sessionSelector: sessionSelector)
         if localIdentifiers.count == 0 { return }
         let assets = PHAsset.fetchAssets(withLocalIdentifiers: localIdentifiers, options: nil)