marinofaggiana 5 years ago
parent
commit
88c8b5f859

+ 24 - 6
iOSClient/Main/CCMain.m

@@ -1048,7 +1048,8 @@
 - (void)uploadFileAsset:(NSArray *)assets urls:(NSArray *)urls serverUrl:(NSString *)serverUrl autoUploadPath:(NSString *)autoUploadPath useSubFolder:(BOOL)useSubFolder session:(NSString *)session
 - (void)uploadFileAsset:(NSArray *)assets urls:(NSArray *)urls serverUrl:(NSString *)serverUrl autoUploadPath:(NSString *)autoUploadPath useSubFolder:(BOOL)useSubFolder session:(NSString *)session
 {
 {
     NSMutableArray *metadatas = [NSMutableArray new];
     NSMutableArray *metadatas = [NSMutableArray new];
-    
+    NSMutableArray *metadatasConflict = [NSMutableArray new];
+
     for (PHAsset *asset in assets) {
     for (PHAsset *asset in assets) {
         
         
         NSString *fileName = [CCUtility createFileName:[asset valueForKey:@"filename"] fileDate:asset.creationDate fileType:asset.mediaType keyFileName:k_keyFileNameMask keyFileNameType:k_keyFileNameType keyFileNameOriginal:k_keyFileNameOriginal];
         NSString *fileName = [CCUtility createFileName:[asset valueForKey:@"filename"] fileDate:asset.creationDate fileType:asset.mediaType keyFileName:k_keyFileNameMask keyFileNameType:k_keyFileNameType keyFileNameOriginal:k_keyFileNameOriginal];
@@ -1089,7 +1090,20 @@
         metadataForUpload.status = k_metadataStatusWaitUpload;
         metadataForUpload.status = k_metadataStatusWaitUpload;
                 
                 
         [metadatas addObject:metadataForUpload];
         [metadatas addObject:metadataForUpload];
-            
+        
+        // verify exists conflict
+        NSString *fileNameExtension = [fileName pathExtension].lowercaseString;
+        NSString *fileNameWithoutExtension = [fileName stringByDeletingPathExtension];
+        NSString *fileNameConflict = fileName;
+        
+        if ([fileNameExtension isEqualToString:@"heic"] && [CCUtility getFormatCompatibility]) {
+            fileNameConflict = [fileNameWithoutExtension stringByAppendingString:@".jpg"];
+        }
+        tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileNameView == %@", appDelegate.activeAccount, serverUrl, fileNameConflict]];
+        if (metadata) {
+            [metadatasConflict addObject:metadata];
+        }
+                    
         // Add Medtadata MOV LIVE PHOTO for upload
         // Add Medtadata MOV LIVE PHOTO for upload
         if ((asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive || asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive+PHAssetMediaSubtypePhotoHDR) && CCUtility.getMOVLivePhoto && urls.count == assets.count) {
         if ((asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive || asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive+PHAssetMediaSubtypePhotoHDR) && CCUtility.getMOVLivePhoto && urls.count == assets.count) {
                 
                 
@@ -1119,15 +1133,19 @@
     }
     }
     
     
     // Verify if file(s) exists
     // Verify if file(s) exists
-    if (metadatas.count > 0) {
+    if (metadatasConflict.count > 0) {
+        
         NCCreateFormUploadConflict *conflict = [[UIStoryboard storyboardWithName:@"NCCreateFormUploadConflict" bundle:nil] instantiateInitialViewController];
         NCCreateFormUploadConflict *conflict = [[UIStoryboard storyboardWithName:@"NCCreateFormUploadConflict" bundle:nil] instantiateInitialViewController];
         conflict.metadatas = metadatas;
         conflict.metadatas = metadatas;
+        conflict.metadatasConflict = metadatasConflict;
         
         
         [self presentViewController:conflict animated:YES completion:nil];
         [self presentViewController:conflict animated:YES completion:nil];
+        
+    } else {
+        
+        [appDelegate startLoadAutoDownloadUpload];
+        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
     }
     }
-    
-    //[appDelegate startLoadAutoDownloadUpload];
-    //[[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
 }
 }
 
 
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------

+ 3 - 2
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -41,9 +41,11 @@ import Foundation
     
     
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     @objc var metadatas: [tableMetadata]
     @objc var metadatas: [tableMetadata]
-    
+    @objc var metadatasConflict: [tableMetadata]
+
     @objc required init?(coder aDecoder: NSCoder) {
     @objc required init?(coder aDecoder: NSCoder) {
         self.metadatas = [tableMetadata]()
         self.metadatas = [tableMetadata]()
+        self.metadatasConflict = [tableMetadata]()
         super.init(coder: aDecoder)
         super.init(coder: aDecoder)
     }
     }
     
     
@@ -57,7 +59,6 @@ import Foundation
     }
     }
 }
 }
 
 
-
 // MARK: - UITableViewDelegate
 // MARK: - UITableViewDelegate
 
 
 extension NCCreateFormUploadConflict: UITableViewDelegate {
 extension NCCreateFormUploadConflict: UITableViewDelegate {