marinofaggiana 4 жил өмнө
parent
commit
82fe6b2b21

+ 1 - 4
iOSClient/NCGlobal.swift

@@ -77,10 +77,7 @@ class NCGlobal: NSObject {
     
     
     // Max Size Upload
     // Max Size Upload
     let uploadMaxFileSize: UInt64                   = 500000000     // 500 MB
     let uploadMaxFileSize: UInt64                   = 500000000     // 500 MB
-    
-    // Chunck size MB
-    let chunckSize: Int                             = 10
-    
+        
     // Max Cache Proxy Video
     // Max Cache Proxy Video
     let maxHTTPCache: Int64                         = 10000000000   // 10 GB
     let maxHTTPCache: Int64                         = 10000000000   // 10 GB
     
     

+ 3 - 2
iOSClient/Networking/NCNetworking.swift

@@ -457,8 +457,9 @@ import Queuer
         var uploadErrorCode: Int = 0
         var uploadErrorCode: Int = 0
         var uploadErrorDescription: String = ""
         var uploadErrorDescription: String = ""
         var counterFileNameInUpload: Int = 0
         var counterFileNameInUpload: Int = 0
-                
-        if let filesNames = NCCommunicationCommon.shared.fileChunks(path: directoryProviderStorageOcId, fileName: metadata.fileName, pathChunks: directoryProviderStorageOcId, sizeInMB: NCGlobal.shared.chunckSize) {
+        let chunkSize = CCUtility.getChunkSize()
+        
+        if let filesNames = NCCommunicationCommon.shared.fileChunks(path: directoryProviderStorageOcId, fileName: metadata.fileName, pathChunks: directoryProviderStorageOcId, sizeInMB: chunkSize) {
         
         
             NCContentPresenter.shared.messageNotification("_info_", description: "_upload_chunk_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode:0, forced: true)
             NCContentPresenter.shared.messageNotification("_info_", description: "_upload_chunk_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode:0, forced: true)
             
             

+ 1 - 1
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -204,7 +204,7 @@ class NCNetworkingProcessUpload: NSObject {
             }
             }
             
             
             // CHUNCK
             // CHUNCK
-            let chunckSize = NCGlobal.shared.chunckSize * 1000000
+            let chunckSize = CCUtility.getChunkSize() * 1000000
             if metadata.size <= chunckSize {
             if metadata.size <= chunckSize {
                 metadatasForUpload.append(metadata)
                 metadatasForUpload.append(metadata)
             } else {
             } else {

+ 20 - 0
iOSClient/Settings/CCAdvanced.m

@@ -122,6 +122,20 @@
         [section addFormRow:row];
         [section addFormRow:row];
     }
     }
     
     
+    // Section : Chunk --------------------------------------------------------------
+
+    section = [XLFormSectionDescriptor formSection];
+    [form addFormSection:section];
+    section.footerTitle = NSLocalizedString(@"_chunk_footer_title_", nil);
+    
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"chunk" rowType:XLFormRowDescriptorTypeStepCounter title:NSLocalizedString(@"_chunk_size_mb_", nil)];
+    row.value = [NSString stringWithFormat:@"%ld", CCUtility.getChunkSize];
+    [row.cellConfigAtConfigure setObject:@YES forKey:@"stepControl.wraps"];
+    [row.cellConfigAtConfigure setObject:@1 forKey:@"stepControl.stepValue"];
+    [row.cellConfigAtConfigure setObject:@1 forKey:@"stepControl.minimumValue"];
+    [row.cellConfigAtConfigure setObject:@100 forKey:@"stepControl.maximumValue"];
+    [section addFormRow:row];
+
     // Section : Privacy --------------------------------------------------------------
     // Section : Privacy --------------------------------------------------------------
 
 
     if (!NCBrandOptions.shared.disable_crash_service) {
     if (!NCBrandOptions.shared.disable_crash_service) {
@@ -343,6 +357,12 @@
         [CCUtility setLogLevel:levelLog];
         [CCUtility setLogLevel:levelLog];
         [[NCCommunicationCommon shared] setLevelLog:levelLog];
         [[NCCommunicationCommon shared] setLevelLog:levelLog];
     }
     }
+    
+    if ([rowDescriptor.tag isEqualToString:@"chunk"]) {
+        
+        NSInteger chunkSize = [[rowDescriptor.value valueData] intValue];
+        [CCUtility setChunkSize:chunkSize];
+    }
 }
 }
 
 
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------

+ 2 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -168,6 +168,8 @@
 "_alias_footer_"            = "Give your account names a descriptive name such as Home, Office, School …";
 "_alias_footer_"            = "Give your account names a descriptive name such as Home, Office, School …";
 "_upload_chunk_"            = "The file you are uploading is large, keep the app in the foreground until complete";
 "_upload_chunk_"            = "The file you are uploading is large, keep the app in the foreground until complete";
 "_upload_e2ee_"             = "The file you are uploading is encrypted, keep the app in the foreground until complete";
 "_upload_e2ee_"             = "The file you are uploading is encrypted, keep the app in the foreground until complete";
+"_chunk_size_mb_"           = "Chunk size in MB";
+"_chunk_footer_title_"      = "Chunked file upload";
 
 
 /* User status */
 /* User status */
 "_online_"                  = "Online";
 "_online_"                  = "Online";

+ 3 - 0
iOSClient/Utility/CCUtility.h

@@ -176,6 +176,9 @@
 + (BOOL)getAccountRequest;
 + (BOOL)getAccountRequest;
 + (void)setAccountRequest:(BOOL)set;
 + (void)setAccountRequest:(BOOL)set;
 
 
++ (NSInteger)getChunkSize;
++ (void)setChunkSize:(NSInteger)size;
+
 // ===== Varius =====
 // ===== Varius =====
 
 
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;

+ 17 - 0
iOSClient/Utility/CCUtility.m

@@ -732,6 +732,23 @@
     [UICKeyChainStore setString:sSet forKey:@"accountRequest" service:NCGlobal.shared.serviceShareKeyChain];
     [UICKeyChainStore setString:sSet forKey:@"accountRequest" service:NCGlobal.shared.serviceShareKeyChain];
 }
 }
 
 
++ (NSInteger)getChunkSize
+{
+    NSString *size = [UICKeyChainStore stringForKey:@"chunkSize" service:NCGlobal.shared.serviceShareKeyChain];
+    
+    if (size == nil) {
+        return 10;
+    } else {
+        return [size integerValue];
+    }
+}
+
++ (void)setChunkSize:(NSInteger)size
+{
+    NSString *sizeString = [@(size) stringValue];
+    [UICKeyChainStore setString:sizeString forKey:@"chunkSize" service:NCGlobal.shared.serviceShareKeyChain];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Various =====
 #pragma mark ===== Various =====
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------