marinofaggiana 4 years ago
parent
commit
5eb25154b4

+ 2 - 2
Cartfile.resolved

@@ -1,4 +1,4 @@
-github "Alamofire/Alamofire" "5.1.0"
+github "Alamofire/Alamofire" "5.2.1"
 github "AssistoLab/DropDown" "v2.3.13"
 github "CocoaLumberjack/CocoaLumberjack" "3.6.1"
 github "FabrizioBrancati/Queuer" "2.1.1"
@@ -20,7 +20,7 @@ github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.6"
 github "marinofaggiana/XLForm" "eb9381ad8129f60402bf412250fb31b95a628a08"
-github "nextcloud/ios-communication-library" "c8161e5ca01af886adde953339829563e527b315"
+github "nextcloud/ios-communication-library" "8a7508ded6e0943b72c7837a77dbb78d0b1b58ea"
 github "realm/realm-cocoa" "v4.4.1"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.5"

+ 1 - 1
iOSClient/CCGlobal.h

@@ -85,7 +85,7 @@
 
 // Database Realm
 #define k_databaseDefault                               @"nextcloud.realm"
-#define k_databaseSchemaVersion                         117
+#define k_databaseSchemaVersion                         120
 
 // Intro selector
 #define k_intro_login                                   0

+ 2 - 2
iOSClient/Database/NCDatabase.swift

@@ -48,8 +48,8 @@ class tableAccount: Object {
     @objc dynamic var company = ""
     @objc dynamic var country = ""
     @objc dynamic var displayName = ""
-    @objc dynamic var dateUpdateMedia: NSDate? = nil
-    @objc dynamic var dateLteMedia: NSDate? = nil
+    @objc dynamic var dateUpdateNewMedia: NSDate? = nil
+    @objc dynamic var dateLessMedia: NSDate? = nil
     @objc dynamic var email = ""
     @objc dynamic var enabled: Bool = false
     @objc dynamic var groups = ""

+ 6 - 15
iOSClient/Database/NCManageDatabase.swift

@@ -99,19 +99,10 @@ class NCManageDatabase: NSObject {
                         migration.deleteData(forType: tableTrash.className())
                     }
                     
-                    if oldSchemaVersion < 95 {
+                    if oldSchemaVersion < 120 {
                         migration.deleteData(forType: tableE2eEncryptionLock.className())
-                    }
-                    
-                    if oldSchemaVersion < 104 {
                         migration.deleteData(forType: tableCapabilities.className())
-                    }
-                    
-                    if oldSchemaVersion < 107 {
                         migration.deleteData(forType: tableComments.className())
-                    }
-                    
-                    if oldSchemaVersion < 113 {
                         migration.deleteData(forType: tableMetadata.className())
                         migration.deleteData(forType: tableDirectory.className())
                     }
@@ -672,7 +663,7 @@ class NCManageDatabase: NSObject {
     }
     #endif
     
-    @objc func setAccountDateUpdateMedia(clear: Bool = false) {
+    @objc func setAccountDateUpdateNewMedia(clear: Bool = false) {
         
         let realm = try! Realm()
 
@@ -680,9 +671,9 @@ class NCManageDatabase: NSObject {
             try realm.write {
                 if let result = realm.objects(tableAccount.self).filter("active == true").first {
                     if clear {
-                        result.dateUpdateMedia = nil
+                        result.dateUpdateNewMedia = nil
                     } else {
-                        result.dateUpdateMedia = Date() as NSDate
+                        result.dateUpdateNewMedia = Date() as NSDate
                     }
                 }
             }
@@ -691,14 +682,14 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func setAccountDateLteMedia(date: NSDate?) {
+    @objc func setAccountDateLessMedia(date: NSDate?) {
         
         let realm = try! Realm()
 
         do {
             try realm.write {
                 if let result = realm.objects(tableAccount.self).filter("active == true").first {
-                    result.dateLteMedia = date
+                    result.dateLessMedia = date
                 }
             }
         } catch let error {

+ 22 - 22
iOSClient/Media/NCMedia.swift

@@ -633,14 +633,14 @@ extension NCMedia {
         //let lteDate: Int = Int(Date().timeIntervalSince1970)
         //let gteDate: Int = Int(fromDate!.timeIntervalSince1970)
         
-        guard let lteDate = Calendar.current.date(byAdding: .second, value: 1, to: Date()) else { return }
-        guard var gteDate = Calendar.current.date(byAdding: .day, value: -30, to: Date()) else { return }
+        guard let lessDate = Calendar.current.date(byAdding: .second, value: 1, to: Date()) else { return }
+        guard var greaterDate = Calendar.current.date(byAdding: .day, value: -30, to: Date()) else { return }
         
-        if let date = tableAccount?.dateUpdateMedia {
-            gteDate = date as Date
+        if let date = tableAccount?.dateUpdateNewMedia {
+            greaterDate = date as Date
         }
                 
-        NCCommunication.shared.searchMedia(lteDate: lteDate, gteDate: gteDate, elementDate: "d:getlastmodified/" ,showHiddenFiles: CCUtility.getShowHiddenFiles(), user: appDelegate.activeUser) { (account, files, errorCode, errorDescription) in
+        NCCommunication.shared.searchMedia(lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/" ,showHiddenFiles: CCUtility.getShowHiddenFiles(), user: appDelegate.activeUser) { (account, files, errorCode, errorDescription) in
             
             self.newInProgress = false
             self.collectionView.reloadData()
@@ -648,38 +648,38 @@ extension NCMedia {
             if errorCode == 0 && files != nil && files!.count > 0 {
                 
                 NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
-                if tableAccount?.dateLteMedia == nil {
-                    NCManageDatabase.sharedInstance.setAccountDateLteMedia(date: files?.last?.date)
+                if tableAccount?.dateLessMedia == nil {
+                    NCManageDatabase.sharedInstance.setAccountDateLessMedia(date: files?.last?.date)
                 }
-                NCManageDatabase.sharedInstance.setAccountDateUpdateMedia()
+                NCManageDatabase.sharedInstance.setAccountDateUpdateNewMedia()
                 
                 self.reloadDataSource()
             }
         }
     }
     
-    private func searchOldPhotoVideo(gteDate: Date? = nil) {
+    private func searchOldPhotoVideo(greaterDate: Date? = nil) {
         
         if oldInProgress { return }
         else { oldInProgress = true }
         collectionView.reloadData()
 
-        var lteDate = Date()
+        var lessDate = Date()
         let tableAccount = NCManageDatabase.sharedInstance.getAccountActive()
-        if let date = tableAccount?.dateLteMedia {
-            lteDate = date as Date
+        if let date = tableAccount?.dateLessMedia {
+            lessDate = date as Date
         }
 
         let height = self.tabBarController?.tabBar.frame.size.height ?? 0
         
-        var gteDate = gteDate
-        if gteDate == nil {
-            gteDate = Calendar.current.date(byAdding: .day, value: -30, to: lteDate)
+        var greaterDate = greaterDate
+        if greaterDate == nil {
+            greaterDate = Calendar.current.date(byAdding: .day, value: -30, to: lessDate)
         }
 
         NCUtility.sharedInstance.startActivityIndicator(view: self.view, bottom: height + 50)
 
-        NCCommunication.shared.searchMedia(lteDate: lteDate, gteDate: gteDate!, elementDate: "d:getlastmodified/" ,showHiddenFiles: CCUtility.getShowHiddenFiles(), user: appDelegate.activeUser) { (account, files, errorCode, errorDescription) in
+        NCCommunication.shared.searchMedia(lessDate: lessDate, greaterDate: greaterDate!, elementDate: "d:getlastmodified/" ,showHiddenFiles: CCUtility.getShowHiddenFiles(), user: appDelegate.activeUser) { (account, files, errorCode, errorDescription) in
             
             self.oldInProgress = false
             NCUtility.sharedInstance.stopActivityIndicator()
@@ -689,17 +689,17 @@ extension NCMedia {
                 if files != nil && files!.count > 0 {
                     
                     NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
-                    NCManageDatabase.sharedInstance.setAccountDateLteMedia(date: files?.last?.date)
+                    NCManageDatabase.sharedInstance.setAccountDateLessMedia(date: files?.last?.date)
                     self.reloadDataSource()
                     
                 } else {
                     
-                    if gteDate == Calendar.current.date(byAdding: .day, value: -30, to: lteDate) {
-                        self.searchOldPhotoVideo(gteDate: Calendar.current.date(byAdding: .day, value: -90, to: lteDate))
-                    } else if gteDate == Calendar.current.date(byAdding: .day, value: -90, to: lteDate) {
-                        self.searchOldPhotoVideo(gteDate: Calendar.current.date(byAdding: .day, value: -180, to: lteDate))
+                    if greaterDate == Calendar.current.date(byAdding: .day, value: -30, to: lessDate) {
+                        self.searchOldPhotoVideo(greaterDate: Calendar.current.date(byAdding: .day, value: -90, to: lessDate))
+                    } else if greaterDate == Calendar.current.date(byAdding: .day, value: -90, to: lessDate) {
+                        self.searchOldPhotoVideo(greaterDate: Calendar.current.date(byAdding: .day, value: -180, to: lessDate))
                     } else {
-                        self.searchOldPhotoVideo(gteDate: Date.distantPast)
+                        self.searchOldPhotoVideo(greaterDate: Date.distantPast)
                     }
                 }
             }

+ 2 - 2
iOSClient/Settings/CCAdvanced.m

@@ -238,8 +238,8 @@
     [KTVHTTPCache cacheDeleteAllCaches];
     
     [[NCManageDatabase sharedInstance] clearDatabaseWithAccount:appDelegate.activeAccount removeAccount:false];
-    [[NCManageDatabase sharedInstance] setAccountDateUpdateMediaWithClear:true];
-    [[NCManageDatabase sharedInstance] setAccountDateLteMediaWithDate:nil];
+    [[NCManageDatabase sharedInstance] setAccountDateUpdateNewMediaWithClear:true];
+    [[NCManageDatabase sharedInstance] setAccountDateLessMediaWithDate:nil];
     
     [CCUtility removeGroupDirectoryProviderStorage];
     [CCUtility removeGroupLibraryDirectory];