marinofaggiana 4 years ago
parent
commit
83ea920d11
2 changed files with 7 additions and 22 deletions
  1. 3 8
      iOSClient/Main/CCMain.m
  2. 4 14
      iOSClient/Networking/CCNetworking.m

+ 3 - 8
iOSClient/Main/CCMain.m

@@ -1180,7 +1180,7 @@
             continue;
         
         // Prepare record metadata
-        tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.activeAccount fileName:fileName ocId:[CCUtility createMetadataIDFromAccount:appDelegate.activeAccount serverUrl:serverUrl fileNameView:fileName directory:false] serverUrl:serverUrl url:@"" contentType:@""];
+        tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.activeAccount fileName:fileName ocId:[[NSUUID UUID] UUIDString] serverUrl:serverUrl url:@"" contentType:@""];
         
         metadataForUpload.assetLocalIdentifier = asset.localIdentifier;
         metadataForUpload.session = session;
@@ -1199,17 +1199,12 @@
                 
             NSUInteger index = [assets indexOfObject:asset];
             NSURL *url = [urls objectAtIndex:index];
-            tableMetadata *metadataMOVForUpload = [tableMetadata new];
             NSString *fileNameNoExt = [fileName stringByDeletingPathExtension];
             NSString *fileName = [NSString stringWithFormat:@"%@.mov", fileNameNoExt];
             unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:url.path error:nil] fileSize];
 
-            metadataMOVForUpload.account = appDelegate.activeAccount;
-            metadataMOVForUpload.date = [NSDate new];
-            metadataMOVForUpload.ocId = [CCUtility createMetadataIDFromAccount:appDelegate.activeAccount serverUrl:serverUrl fileNameView:fileName directory:false];
-            metadataMOVForUpload.fileName = fileName;
-            metadataMOVForUpload.fileNameView = fileName;
-            metadataMOVForUpload.serverUrl = serverUrl;
+            tableMetadata *metadataMOVForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.activeAccount fileName:fileName ocId:[[NSUUID UUID] UUIDString] serverUrl:serverUrl url:@"" contentType:@""];
+            
             metadataMOVForUpload.session = session;
             metadataMOVForUpload.sessionSelector = selectorUploadFile;
             metadataMOVForUpload.size = fileSize;

+ 4 - 14
iOSClient/Networking/CCNetworking.m

@@ -991,23 +991,13 @@
             metadata.sessionTaskIdentifier = k_taskIdentifierDone;
             metadata.status = k_metadataStatusNormal;
             
+            [CCUtility moveFileAtPath:[NSString stringWithFormat:@"%@/%@", [CCUtility getDirectoryProviderStorage], tempocId] toPath:[NSString stringWithFormat:@"%@/%@", [CCUtility getDirectoryProviderStorage], metadata.ocId]];
+            
             [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileName == %@", metadata.account, metadata.serverUrl, metadata.fileName]];
-            metadata = [[NCManageDatabase sharedInstance] addMetadata:metadata];
             
-            NSLog(@"[LOG] Insert new upload : %@ - ocId : %@", metadata.fileName, ocId);
+            metadata = [[NCManageDatabase sharedInstance] addMetadata:metadata];            
             
-            if ([tempocId isEqualToString:[CCUtility createMetadataIDFromAccount:metadata.account serverUrl:metadata.serverUrl fileNameView:metadata.fileNameView directory:metadata.directory]]) {
-                
-                [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", tempocId]];
-                
-                // adjust file system Directory Provider Storage
-                if ([tempSession isEqualToString:k_upload_session_extension]) {
-                    // this is for File Provider Extension [Apple Works and ... ?]
-                    [CCUtility copyFileAtPath:[NSString stringWithFormat:@"%@/%@", [CCUtility getDirectoryProviderStorage], tempocId] toPath:[NSString stringWithFormat:@"%@/%@", [CCUtility getDirectoryProviderStorage], metadata.ocId]];
-                } else {
-                    [CCUtility moveFileAtPath:[NSString stringWithFormat:@"%@/%@", [CCUtility getDirectoryProviderStorage], tempocId] toPath:[NSString stringWithFormat:@"%@/%@", [CCUtility getDirectoryProviderStorage], metadata.ocId]];
-                }
-            }
+            NSLog(@"[LOG] Insert new upload : %@ - ocId : %@", metadata.fileName, ocId);
         }
 #ifndef EXTENSION