Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'iOSClient/Data/NCManageDatabase.swift')
-rw-r--r--iOSClient/Data/NCManageDatabase.swift126
1 files changed, 63 insertions, 63 deletions
diff --git a/iOSClient/Data/NCManageDatabase.swift b/iOSClient/Data/NCManageDatabase.swift
index 10459c812..68833bb56 100644
--- a/iOSClient/Data/NCManageDatabase.swift
+++ b/iOSClient/Data/NCManageDatabase.swift
@@ -24,7 +24,7 @@
import UIKit
import RealmSwift
-import NCCommunication
+import NextcloudKit
import SwiftyJSON
import CoreMedia
import Photos
@@ -46,9 +46,9 @@ class NCManageDatabase: NSObject {
if let databaseFilePath = databaseFileUrlPath?.path {
if FileManager.default.fileExists(atPath: databaseFilePath) {
- NCCommunicationCommon.shared.writeLog("DATABASE FOUND in " + databaseFilePath)
+ NKCommon.shared.writeLog("DATABASE FOUND in " + databaseFilePath)
} else {
- NCCommunicationCommon.shared.writeLog("DATABASE NOT FOUND in " + databaseFilePath)
+ NKCommon.shared.writeLog("DATABASE NOT FOUND in " + databaseFilePath)
}
}
@@ -70,7 +70,7 @@ class NCManageDatabase: NSObject {
let config = Realm.Configuration(
fileURL: dirGroup?.appendingPathComponent(NCGlobal.shared.appDatabaseNextcloud + "/" + NCGlobal.shared.databaseDefault),
schemaVersion: NCGlobal.shared.databaseSchemaVersion,
- objectTypes: [tableMetadata.self, tableLocalFile.self, tableDirectory.self, tableTag.self, tableAccount.self, tableCapabilities.self, tableE2eEncryption.self, tableE2eEncryptionLock.self, tableShare.self, tableChunk.self, tableAvatar.self]
+ objectTypes: [tableMetadata.self, tableLocalFile.self, tableDirectory.self, tableTag.self, tableAccount.self, tableCapabilities.self, tablePhotoLibrary.self, tableE2eEncryption.self, tableE2eEncryptionLock.self, tableShare.self, tableChunk.self, tableAvatar.self, tableDashboardWidget.self, tableDashboardWidgetButton.self]
)
Realm.Configuration.defaultConfiguration = config
@@ -188,9 +188,10 @@ class NCManageDatabase: NSObject {
if let databaseFileUrlPath = databaseFileUrlPath {
do {
#if !EXTENSION
- NCContentPresenter.shared.messageNotification("_error_", description: "_database_corrupt_", delay: NCGlobal.shared.dismissAfterSecondLong, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, priority: .max)
+ let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_database_corrupt_")
+ NCContentPresenter.shared.showError(error: error, priority: .max)
#endif
- NCCommunicationCommon.shared.writeLog("DATABASE CORRUPT: removed")
+ NKCommon.shared.writeLog("DATABASE CORRUPT: removed")
try FileManager.default.removeItem(at: databaseFileUrlPath)
} catch {}
}
@@ -211,9 +212,10 @@ class NCManageDatabase: NSObject {
if let databaseFileUrlPath = databaseFileUrlPath {
do {
#if !EXTENSION
- NCContentPresenter.shared.messageNotification("_error_", description: "_database_corrupt_", delay: NCGlobal.shared.dismissAfterSecondLong, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, priority: .max)
+ let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_database_corrupt_")
+ NCContentPresenter.shared.showError(error: error, priority: .max)
#endif
- NCCommunicationCommon.shared.writeLog("DATABASE CORRUPT: removed")
+ NKCommon.shared.writeLog("DATABASE CORRUPT: removed")
try FileManager.default.removeItem(at: databaseFileUrlPath)
} catch {}
}
@@ -243,7 +245,7 @@ class NCManageDatabase: NSObject {
realm.delete(results)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -257,6 +259,8 @@ class NCManageDatabase: NSObject {
self.clearTable(tableCapabilities.self, account: account)
self.clearTable(tableChunk.self, account: account)
self.clearTable(tableComments.self, account: account)
+ self.clearTable(tableDashboardWidget.self, account: account)
+ self.clearTable(tableDashboardWidgetButton.self, account: account)
self.clearTable(tableDirectEditingCreators.self, account: account)
self.clearTable(tableDirectEditingEditors.self, account: account)
self.clearTable(tableDirectory.self, account: account)
@@ -292,7 +296,7 @@ class NCManageDatabase: NSObject {
do {
try FileManager.default.removeItem(at: URL)
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
}
@@ -337,7 +341,7 @@ class NCManageDatabase: NSObject {
realm.add(addObject, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -366,7 +370,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -389,7 +393,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
return image
@@ -428,7 +432,7 @@ class NCManageDatabase: NSObject {
realm.add(addObject, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -570,7 +574,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -596,7 +600,7 @@ class NCManageDatabase: NSObject {
realm.delete(result)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -611,14 +615,14 @@ class NCManageDatabase: NSObject {
realm.delete(result)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
// MARK: -
// MARK: Table Direct Editing
- @objc func addDirectEditing(account: String, editors: [NCCommunicationEditorDetailsEditors], creators: [NCCommunicationEditorDetailsCreators]) {
+ @objc func addDirectEditing(account: String, editors: [NKEditorDetailsEditors], creators: [NKEditorDetailsCreators]) {
let realm = try! Realm()
@@ -669,7 +673,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -747,7 +751,7 @@ class NCManageDatabase: NSObject {
realm.add(addObject, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -770,7 +774,7 @@ class NCManageDatabase: NSObject {
realm.delete(results)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -809,7 +813,7 @@ class NCManageDatabase: NSObject {
realm.add(directory, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -847,7 +851,7 @@ class NCManageDatabase: NSObject {
result?.serverUrl = serverUrl
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -861,7 +865,7 @@ class NCManageDatabase: NSObject {
result?.offline = offline
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -877,7 +881,7 @@ class NCManageDatabase: NSObject {
result?.richWorkspace = richWorkspace
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
if let result = result {
@@ -899,7 +903,7 @@ class NCManageDatabase: NSObject {
result?.colorFolder = colorFolder
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
if let result = result {
@@ -921,7 +925,7 @@ class NCManageDatabase: NSObject {
realm.add(e2e, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -936,7 +940,7 @@ class NCManageDatabase: NSObject {
realm.delete(results)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -997,7 +1001,7 @@ class NCManageDatabase: NSObject {
do {
try realm.commitWrite()
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1031,7 +1035,7 @@ class NCManageDatabase: NSObject {
realm.add(addObject, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1046,14 +1050,14 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
// MARK: -
// MARK: Table External Sites
- @objc func addExternalSites(_ externalSite: NCCommunicationExternalSite, account: String) {
+ @objc func addExternalSites(_ externalSite: NKExternalSite, account: String) {
let realm = try! Realm()
@@ -1072,7 +1076,7 @@ class NCManageDatabase: NSObject {
realm.add(addObject)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1086,7 +1090,7 @@ class NCManageDatabase: NSObject {
realm.delete(results)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1135,7 +1139,7 @@ class NCManageDatabase: NSObject {
do {
try realm.commitWrite()
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1174,7 +1178,7 @@ class NCManageDatabase: NSObject {
realm.add(addObject, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1198,7 +1202,7 @@ class NCManageDatabase: NSObject {
realm.add(addObject, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1212,7 +1216,7 @@ class NCManageDatabase: NSObject {
realm.delete(results)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1231,7 +1235,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1251,7 +1255,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1292,7 +1296,7 @@ class NCManageDatabase: NSObject {
result?.offline = offline
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1334,7 +1338,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
return false
}
@@ -1369,7 +1373,7 @@ class NCManageDatabase: NSObject {
// MARK: -
// MARK: Table Share
- @objc func addShare(urlBase: String, account: String, shares: [NCCommunicationShare]) {
+ @objc func addShare(urlBase: String, account: String, shares: [NKShare]) {
let realm = try! Realm()
realm.beginWrite()
@@ -1427,7 +1431,7 @@ class NCManageDatabase: NSObject {
do {
try realm.commitWrite()
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1446,17 +1450,13 @@ class NCManageDatabase: NSObject {
let realm = try! Realm()
let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idShare", ascending: false)]
-
let firstShareLink = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND shareType == 3", metadata.account, metadata.serverUrl, metadata.fileName).first
- if firstShareLink == nil {
-
- let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@", metadata.account, metadata.serverUrl, metadata.fileName).sorted(by: sortProperties)
- return(firstShareLink: firstShareLink, share: Array(results.map { tableShare.init(value: $0) }))
-
+ if let firstShareLink = firstShareLink {
+ let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND idShare != %d", metadata.account, metadata.serverUrl, metadata.fileName, firstShareLink.idShare).sorted(by: sortProperties)
+ return(firstShareLink: tableShare.init(value: firstShareLink), share: Array(results.map { tableShare.init(value: $0) }))
} else {
-
- let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND idShare != %d", metadata.account, metadata.serverUrl, metadata.fileName, firstShareLink!.idShare).sorted(by: sortProperties)
+ let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@", metadata.account, metadata.serverUrl, metadata.fileName).sorted(by: sortProperties)
return(firstShareLink: firstShareLink, share: Array(results.map { tableShare.init(value: $0) }))
}
}
@@ -1504,7 +1504,7 @@ class NCManageDatabase: NSObject {
do {
try realm.commitWrite()
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1520,7 +1520,7 @@ class NCManageDatabase: NSObject {
do {
try realm.commitWrite()
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1544,7 +1544,7 @@ class NCManageDatabase: NSObject {
realm.add(addObject, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1560,7 +1560,7 @@ class NCManageDatabase: NSObject {
do {
try realm.commitWrite()
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1611,14 +1611,14 @@ class NCManageDatabase: NSObject {
realm.add(addObject, update: .all)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
// MARK: -
// MARK: Table Trash
- @objc func addTrash(account: String, items: [NCCommunicationTrash]) {
+ @objc func addTrash(account: String, items: [NKTrash]) {
let realm = try! Realm()
@@ -1646,7 +1646,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1668,7 +1668,7 @@ class NCManageDatabase: NSObject {
realm.delete(result)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1690,7 +1690,7 @@ class NCManageDatabase: NSObject {
realm.delete(result)
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
@@ -1719,7 +1719,7 @@ class NCManageDatabase: NSObject {
// MARK: -
// MARK: Table UserStatus
- @objc func addUserStatus(_ userStatuses: [NCCommunicationUserStatus], account: String, predefined: Bool) {
+ @objc func addUserStatus(_ userStatuses: [NKUserStatus], account: String, predefined: Bool) {
let realm = try! Realm()
@@ -1748,7 +1748,7 @@ class NCManageDatabase: NSObject {
}
}
} catch let error {
- NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+ NKCommon.shared.writeLog("Could not write to database: \(error)")
}
}
}