Przeglądaj źródła

Remove option enable/disable the detect modified photo/video now only new foto (no modified)

Marino Faggiana 7 lat temu
rodzic
commit
9e7cc6ae5f

+ 14 - 9
iOSClient/AppDelegate.m

@@ -1679,7 +1679,7 @@
 #endif
     
     NSString *actualVersion = [CCUtility getVersion];
-    //NSString *actualBuild = [CCUtility getBuild];
+    NSString *actualBuild = [CCUtility getBuild];
     
     /* ---------------------- UPGRADE VERSION ----------------------- */
     
@@ -1727,18 +1727,23 @@
         [self maintenanceMode:NO];
     }
     
-    // VERSION == 2.17.4
+    // VERSION < 2.17.6
 
-    if ([actualVersion isEqualToString:@"2.17.4"]) {
+    if (([actualVersion compare:@"2.17.6" options:NSNumericSearch] == NSOrderedAscending)) {
         
-        // Build < 37 (example)
-        /*
-        if (([actualBuild compare:@"37" options:NSNumericSearch] == NSOrderedAscending) || actualBuild == nil) {
+        // Remove All old Photo Library
+        [[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:nil];
+    }
+    
+    // VERSION == 2.17.6
+    if ([actualVersion isEqualToString:@"2.17.6"]) {
+        
+        // Build < 10
+        if (([actualBuild compare:@"10" options:NSNumericSearch] == NSOrderedAscending) || actualBuild == nil) {
             
-            [CCUtility setOrderSettings:@"fileName"];
-            [CCUtility setBuild];
+            // Remove All old Photo Library
+            [[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:nil];
         }
-        */ 
     }
     
     return YES;

+ 9 - 21
iOSClient/AutoUpload/NCAutoUpload.m

@@ -568,29 +568,18 @@
             
             if (assetsFull == NO) {
             
-                NSPredicate *predicate;
                 NSString *creationDate;
-                NSString *modificationDate;
-                BOOL detectModificationDateCameraRollAsset = [CCUtility getDetectModificationDateCameraRollAsset];
+                NSString *idAsset;
 
                 NSArray *idsAsset = [[NCManageDatabase sharedInstance] getPhotoLibraryIdAssetWithImage:account.autoUploadImage video:account.autoUploadVideo];
                 
                 for (PHAsset *asset in assets) {
                     
                     (asset.creationDate != nil) ? (creationDate = [NSString stringWithFormat:@"%@", asset.creationDate]) : (creationDate = @"");
-                    (asset.modificationDate != nil) ? (modificationDate = [NSString stringWithFormat:@"%@", asset.modificationDate]) : (modificationDate = @"");
                     
-                    if (detectModificationDateCameraRollAsset) {
-                        NSString *idAsset = [NSString stringWithFormat:@"%@%@%@%@", account.account, asset.localIdentifier, creationDate, modificationDate];
-                        predicate = [NSPredicate predicateWithFormat:@"SELF = %@", idAsset];
-                    } else {
-                        NSString *idAsset = [NSString stringWithFormat:@"%@%@%@", account.account, asset.localIdentifier, creationDate];
-                        predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", idAsset];
-                    }
+                    idAsset = [NSString stringWithFormat:@"%@%@%@", account.account, asset.localIdentifier, creationDate];
                     
-                    NSArray *filteredArray = [idsAsset filteredArrayUsingPredicate: predicate];
-                    
-                    if ([filteredArray count] == 0)
+                    if (![idsAsset containsObject: idAsset])
                         [newAssets addObject:asset];
                 }
                 
@@ -612,15 +601,14 @@
 
 - (void)alignPhotoLibrary
 {
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-        
-        tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
 
-        PHFetchResult *assets = [self getCameraRollAssets:account assetsFull:YES alignPhotoLibrary:YES];
-        (void)[[NCManageDatabase sharedInstance] addPhotoLibrary:(NSArray *)assets];
+    PHFetchResult *assets = [self getCameraRollAssets:account assetsFull:YES alignPhotoLibrary:YES];
+        
+    [[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:app.activeAccount];
+    (void)[[NCManageDatabase sharedInstance] addPhotoLibrary:(NSArray *)assets];
 
-        NSLog(@"Align Photo Library %lu", (unsigned long)[assets count]);
-    });
+    NSLog(@"Align Photo Library %lu", (unsigned long)[assets count]);
 }
 
 @end

+ 1 - 1
iOSClient/Brand/Picker.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.17.6</string>
 	<key>CFBundleVersion</key>
-	<string>00009</string>
+	<string>00010</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/PickerFileProvider.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.17.6</string>
 	<key>CFBundleVersion</key>
-	<string>00009</string>
+	<string>00010</string>
 	<key>NSExtension</key>
 	<dict>
 		<key>NSExtensionFileProviderDocumentGroup</key>

+ 1 - 1
iOSClient/Brand/Share.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.17.6</string>
 	<key>CFBundleVersion</key>
-	<string>00009</string>
+	<string>00010</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/iOSClient.plist

@@ -69,7 +69,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>00009</string>
+	<string>00010</string>
 	<key>Fabric</key>
 	<dict>
 		<key>APIKey</key>

+ 11 - 6
iOSClient/Database/NCManageDatabase.swift

@@ -1586,7 +1586,6 @@ class NCManageDatabase: NSObject {
                 try realm.write {
                 
                     var creationDateString = ""
-                    var modificationDateString = ""
 
                     for asset in assets {
                     
@@ -1605,12 +1604,9 @@ class NCManageDatabase: NSObject {
                         
                         if let modificationDate = asset.modificationDate {
                             addObject.modificationDate = modificationDate as NSDate
-                            modificationDateString = String(describing: modificationDate)
-                        } else {
-                            modificationDateString = ""
                         }
                         
-                        addObject.idAsset = "\(tableAccount.account)\(asset.localIdentifier)\(creationDateString)\(modificationDateString)"
+                        addObject.idAsset = "\(tableAccount.account)\(asset.localIdentifier)\(creationDateString)"
 
                         realm.add(addObject, update: true)
                     }
@@ -1653,7 +1649,16 @@ class NCManageDatabase: NSObject {
         
         return Array(idsAsset)
     }
-
+    
+    func getPhotoLibrary(predicate: NSPredicate) -> [tablePhotoLibrary] {
+        
+        let realm = try! Realm()
+        
+        let results = realm.objects(tablePhotoLibrary.self).filter(predicate)
+        
+        return Array(results.map { tablePhotoLibrary.init(value:$0) })
+    }
+    
     //MARK: -
     //MARK: Table Queue Download
     

+ 6 - 0
iOSClient/Main/CCMain.m

@@ -373,6 +373,12 @@
         // remove all Notification Messages
         [appDelegate.listOfNotifications removeAllObjects];
         
+        // Not Photos Video in library ? then align
+        NSArray *recordsPhotoLibrary = [[NCManageDatabase sharedInstance] getPhotoLibraryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@", app.activeAccount]];
+        if ([recordsPhotoLibrary count] == 0) {
+            [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+        }
+        
         // Initializations
         [appDelegate applicationInitialized];
                 

+ 0 - 4
iOSClient/Main/CCMore.swift

@@ -383,10 +383,6 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
 
     func loginSuccess(_ loginType: NSInteger) {
         
-        if (UInt32(loginType) != loginModifyPasswordUser.rawValue) {
-            NCAutoUpload.sharedInstance().alignPhotoLibrary()
-        }
-        
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil)
         
         appDelegate.selectedTabBarController(Int(k_tabBarApplicationIndexFile))

+ 0 - 4
iOSClient/Main/CCSplit.m

@@ -131,10 +131,6 @@
 
 - (void)loginSuccess:(NSInteger)loginType
 {
-    // Align Photo Library
-    if (loginType != loginModifyPasswordUser)
-        [[NCAutoUpload sharedInstance] alignPhotoLibrary];
-    
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
 }
 

+ 4 - 1
iOSClient/Settings/CCAdvanced.m

@@ -335,6 +335,8 @@
         [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:app.activeAccount];
         [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:app.activeAccount];
         
+        [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+        
         [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl removeIco:removeIco];
         
         [self emptyLocalDirectory];
@@ -367,7 +369,8 @@
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_thumbnails_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
         
         [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil)
-                                                             style:UIAlertActionStyleDefault                                                         handler:^(UIAlertAction *action) {
+                                                             style:UIAlertActionStyleDefault
+                                                           handler:^(UIAlertAction *action) {
                                                                [self removeAllFiles:YES];
                                                            }]];
         

+ 0 - 4
iOSClient/Settings/CCManageAccount.m

@@ -187,10 +187,6 @@
 
 - (void)loginSuccess:(NSInteger)loginType
 {
-    // Align Photo Library
-    if (loginType != loginModifyPasswordUser)
-        [[NCAutoUpload sharedInstance] alignPhotoLibrary];
-
     if (loginType == loginAddForced)
         [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
 }

+ 13 - 32
iOSClient/Settings/CCManageAutoUpload.m

@@ -165,18 +165,6 @@
     row.action.viewControllerClass = [NCManageAutoUploadFileName class];
     [section addFormRow:row];
     
-    // Detect Modification Date CameraRoll Asset
-    
-    section = [XLFormSectionDescriptor formSection];
-    [form addFormSection:section];
-    
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"detectModificationDateCameraRollAsset" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_autoupload_detectModificationAsset_", nil)];
-    row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
-    if ([CCUtility getDetectModificationDateCameraRollAsset]) row.value = @1;
-    else row.value = @0;
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
-    [section addFormRow:row];
-
     // end
     
     section = [XLFormSectionDescriptor formSection];
@@ -240,7 +228,9 @@
                 [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadVideo" state:YES];
             }
             
-            [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
+                [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+            });
             
         } else {
             
@@ -302,8 +292,11 @@
         
         [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadImage" state:[[rowDescriptor.value valueData] boolValue]];
 
-        if ([[rowDescriptor.value valueData] boolValue] == YES)
-            [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+        if ([[rowDescriptor.value valueData] boolValue] == YES) {
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
+                [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+            });
+        }
     }
     
     if ([rowDescriptor.tag isEqualToString:@"autoUploadWWAnPhoto"]) {
@@ -315,8 +308,11 @@
     
         [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadVideo" state:[[rowDescriptor.value valueData] boolValue]];
 
-        if ([[rowDescriptor.value valueData] boolValue] == YES)
-            [[NCAutoUpload sharedInstance] alignPhotoLibrary];            
+        if ([[rowDescriptor.value valueData] boolValue] == YES){
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
+                [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+            });
+        }
     }
     
     if ([rowDescriptor.tag isEqualToString:@"autoUploadWWAnVideo"]) {
@@ -328,11 +324,6 @@
         
         [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadCreateSubfolder" state:[[rowDescriptor.value valueData] boolValue]];
     }
-    
-    if ([rowDescriptor.tag isEqualToString:@"detectModificationDateCameraRollAsset"]) {
-        
-        [CCUtility setDetectModificationDateCameraRollAsset:[[rowDescriptor.value valueData] boolValue]];
-    }
 }
 
 - (void)done:(XLFormRowDescriptor *)sender
@@ -360,8 +351,6 @@
 
     XLFormRowDescriptor *rowAutoUploadFileName = [self.form formRowWithTag:@"autoUploadFileName"];
     
-    XLFormRowDescriptor *rowDetectModificationDateCameraRollAsset = [self.form formRowWithTag:@"detectModificationDateCameraRollAsset"];
-
     // - STATUS ---------------------
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
     
@@ -389,8 +378,6 @@
     if (tableAccount.autoUploadCreateSubfolder)
         [rowAutoUploadCreateSubfolder setValue:@1]; else [rowAutoUploadCreateSubfolder setValue:@0];
     
-    if ([CCUtility getDetectModificationDateCameraRollAsset])
-        [rowDetectModificationDateCameraRollAsset setValue:@1]; else [rowDetectModificationDateCameraRollAsset setValue:@0];
 
     // - HIDDEN --------------------------------------------------------------------------
     
@@ -408,8 +395,6 @@
     
     rowAutoUploadFileName.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     
-    rowDetectModificationDateCameraRollAsset.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
-
     // -----------------------------------------------------------------------------------
     
     [self.tableView reloadData];
@@ -443,10 +428,6 @@
             if (tableAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_filenamemask_footer_", nil);
             else sectionName = @"";
             break;
-        case 7:
-            if (tableAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_detectModificationAsset_footer_", nil);
-            else sectionName = @"";
-            break;
     }
     return sectionName;
 }

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

@@ -178,9 +178,6 @@
 "_autoupload_create_subfolder_footer_" = "Store in subfolders based on year and month";
 "_autoupload_filenamemask_"         = "Change filename mask";
 "_autoupload_filenamemask_footer_"  = "Change the automatic filename mask";
-"_autoupload_detectModificationAsset_" = "Detect modified photo/video";
-"_autoupload_detectModificationAsset_footer_" = "In addition to detecting new photos/videos it also detects modified photos/videos";
-
 
 // Manage Crypto Cloud
 

+ 0 - 4
iOSClient/Utility/CCUtility.h

@@ -93,8 +93,6 @@
 
 + (void)setShowHiddenFiles:(BOOL)show;
 
-+ (void)setDetectModificationDateCameraRollAsset:(BOOL)detect;
-
 // GET
 
 + (NSString *)getKeyChainPasscodeForUUID:(NSString *)uuid;
@@ -141,8 +139,6 @@
 
 + (BOOL)getShowHiddenFiles;
 
-+ (BOOL)getDetectModificationDateCameraRollAsset;
-
 // ===== Varius =====
 
 + (NSString *)getUserAgent;

+ 0 - 11
iOSClient/Utility/CCUtility.m

@@ -227,12 +227,6 @@
     [UICKeyChainStore setString:sShow forKey:@"showHiddenFiles" service:k_serviceShareKeyChain];
 }
 
-+ (void)setDetectModificationDateCameraRollAsset:(BOOL)detect
-{
-    NSString *sDetect = (detect) ? @"true" : @"false";
-    [UICKeyChainStore setString:sDetect forKey:@"detectModificationDateCameraRollAsset" service:k_serviceShareKeyChain];
-}
-
 #pragma ------------------------------ GET
 
 + (NSString *)getKeyChainPasscodeForUUID:(NSString *)uuid
@@ -437,11 +431,6 @@
     return [[UICKeyChainStore stringForKey:@"showHiddenFiles" service:k_serviceShareKeyChain] boolValue];
 }
 
-+ (BOOL)getDetectModificationDateCameraRollAsset
-{
-    return [[UICKeyChainStore stringForKey:@"detectModificationDateCameraRollAsset" service:k_serviceShareKeyChain] boolValue];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Varius =====
 #pragma --------------------------------------------------------------------------------------------