Marino Faggiana 1 年間 前
コミット
b198b62b60

+ 2 - 1
iOSClient/Data/NCManageDatabase+Video.swift

@@ -25,7 +25,8 @@ import Foundation
 import RealmSwift
 import NextcloudKit
 
-class tableVideo: Object {
+typealias tableVideo = tableVideoV2
+class tableVideoV2: Object {
 
     @objc dynamic var account = ""
     @objc dynamic var ocId = ""

+ 13 - 9
iOSClient/Data/NCManageDatabase.swift

@@ -95,6 +95,10 @@ class NCManageDatabase: NSObject {
                         migration.deleteData(forType: tableMetadata.className())
                     }
 
+                    if oldSchemaVersion < 292 {
+                        migration.deleteData(forType: tableVideo.className())
+                    }
+
                 }, shouldCompactOnLaunch: { totalBytes, usedBytes in
 
                     // totalBytes refers to the size of the file on disk in bytes (data + free space)
@@ -108,14 +112,14 @@ class NCManageDatabase: NSObject {
 
             do {
                 _ = try Realm(configuration: configCompact)
-            } catch {
+            } catch let error {
                 if let databaseFileUrlPath = databaseFileUrlPath {
                     do {
 #if !EXTENSION
-                        let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_database_corrupt_")
-                        NCContentPresenter.shared.showError(error: error, priority: .max)
+                        let nkError = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: error.localizedDescription)
+                        NCContentPresenter.shared.showError(error: nkError, priority: .max)
 #endif
-                        NextcloudKit.shared.nkCommonInstance.writeLog("DATABASE CORRUPT: removed")
+                        NextcloudKit.shared.nkCommonInstance.writeLog("DATABASE ERROR: \(error.localizedDescription)")
                         try FileManager.default.removeItem(at: databaseFileUrlPath)
                     } catch {}
                 }
@@ -132,16 +136,16 @@ class NCManageDatabase: NSObject {
         // Verify Database, if corrupt remove it
         do {
             _ = try Realm()
-        } catch {
+        } catch let error {
             if let databaseFileUrlPath = databaseFileUrlPath {
                 do {
 #if !EXTENSION
-                    let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_database_corrupt_")
-                    NCContentPresenter.shared.showError(error: error, priority: .max)
+                    let nkError = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: error.localizedDescription)
+                    NCContentPresenter.shared.showError(error: nkError, priority: .max)
 #endif
-                    NextcloudKit.shared.nkCommonInstance.writeLog("DATABASE CORRUPT: removed")
+                    NextcloudKit.shared.nkCommonInstance.writeLog("DATABASE ERROR: \(error.localizedDescription)")
                     try FileManager.default.removeItem(at: databaseFileUrlPath)
-                } catch {}
+                } catch { }
             }
         }