marinofaggiana 3 years ago
parent
commit
3af0b9e473

+ 5 - 1
iOSClient/Settings/CCAdvanced.m

@@ -235,9 +235,13 @@
     
     
     // Section : Delete files / Clear cache --------------------------------------------------------------
     // Section : Delete files / Clear cache --------------------------------------------------------------
 
 
+    NSString *directory = CCUtility.getDirectoryProviderStorage;
+    int64_t totalSize = [[NCUtilityFileSystem shared] getDirectorySizeWithDirectory:directory];
+    NSString *footerTitle = [NSString stringWithFormat:@"%@. (%@ %@)", NSLocalizedString(@"_clear_cache_footer_", nil), NSLocalizedString(@"_used_space_", nil), [CCUtility transformedSize:totalSize]];
+    
     section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_delete_files_desc_", nil)];
     section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_delete_files_desc_", nil)];
     [form addFormSection:section];
     [form addFormSection:section];
-    section.footerTitle = NSLocalizedString(@"_clear_cache_footer_", nil);
+    section.footerTitle = footerTitle;
 
 
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deleteoldfiles" rowType:XLFormRowDescriptorTypeSelectorPush title:NSLocalizedString(@"_delete_old_files_", nil)];
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deleteoldfiles" rowType:XLFormRowDescriptorTypeSelectorPush title:NSLocalizedString(@"_delete_old_files_", nil)];
     
     

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

@@ -812,6 +812,7 @@
 "_1_months_"                = "1 months";
 "_1_months_"                = "1 months";
 "_1_week_"                  = "1 week";
 "_1_week_"                  = "1 week";
 "_1_day_"                   = "1 day";
 "_1_day_"                   = "1 day";
+"_used_space_"              = "Used space";
 
 
 // ----------------------------------------------------------------------------------------------------------------------------------
 // ----------------------------------------------------------------------------------------------------------------------------------
 // IM
 // IM

+ 19 - 0
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -240,6 +240,25 @@ class NCUtilityFileSystem: NSObject {
         return resultFileName
         return resultFileName
     }
     }
     
     
+    @objc func getDirectorySize(directory: String) -> Int64 {
+        
+        let url = URL(fileURLWithPath: directory)
+        let manager = FileManager.default
+        var totalSize: Int64 = 0
+        
+        if let enumerator = manager.enumerator(at: url, includingPropertiesForKeys: [.isRegularFileKey], options: []) {
+            for case let fileURL as URL in enumerator {
+                if let attributes = try? manager.attributesOfItem(atPath: fileURL.path) {
+                    if let size = attributes[.size] as? Int64 {
+                        totalSize = totalSize + size
+                    }
+                }
+            }
+        }
+        
+        return totalSize
+    }
+    
     func cleanUp(directory: String, days: TimeInterval) {
     func cleanUp(directory: String, days: TimeInterval) {
         
         
         if days == 0 { return}
         if days == 0 { return}