Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
This commit is contained in:
Marino Faggiana 2023-11-30 10:41:55 +01:00
Родитель 1b9713452e
Коммит 4e23125e20
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 2F5F63C3EF460487
5 изменённых файлов: 22 добавлений и 17 удалений

Просмотреть файл

@ -26,4 +26,4 @@ import Foundation
// Database Realm
//
let databaseName = "nextcloud.realm"
let databaseSchemaVersion: UInt64 = 330
let databaseSchemaVersion: UInt64 = 331

Просмотреть файл

@ -60,9 +60,9 @@ class tableMetadata: Object, NCUserBaseUrl {
@objc dynamic var hidden: Bool = false
@objc dynamic var iconName = ""
@objc dynamic var iconUrl = ""
@objc dynamic var isFlaggedAsLivePhotoByServer: Bool = false
@objc dynamic var isExtractFile: Bool = false
@objc dynamic var livePhotoFile = ""
@objc dynamic var livePhotoServer: Bool = false
@objc dynamic var mountType = ""
@objc dynamic var name = "" // for unifiedSearch is the provider.id
@objc dynamic var note = ""
@ -346,7 +346,7 @@ extension NCManageDatabase {
metadata.height = file.height
metadata.width = file.width
metadata.livePhotoFile = file.livePhotoFile
metadata.livePhotoServer = file.livePhotoServer
metadata.isFlaggedAsLivePhotoByServer = file.isFlaggedAsLivePhotoByServer
// E2EE find the fileName for fileNameView
if isDirectoryE2EE || file.e2eEncrypted {
@ -715,13 +715,13 @@ extension NCManageDatabase {
}
}
func setMetadataLivePhotoServer(account: String, ocId: String) {
func setMetadataLivePhotoByServer(account: String, ocId: String) {
do {
let realm = try Realm()
try realm.write {
let result = realm.objects(tableMetadata.self).filter("account == %@ AND ocId == %@", account, ocId).first
result?.livePhotoServer = true
result?.isFlaggedAsLivePhotoByServer = true
}
} catch let error {
NextcloudKit.shared.nkCommonInstance.writeLog("Could not write to database: \(error)")

Просмотреть файл

@ -123,7 +123,7 @@ class NCManageDatabase: NSObject {
migration.deleteData(forType: tableGPS.className())
}
if oldSchemaVersion < 330 {
if oldSchemaVersion < 331 {
migration.deleteData(forType: tableMetadata.className())
migration.enumerateObjects(ofType: tableDirectory.className()) { _, newObject in
newObject?["etag"] = ""

Просмотреть файл

@ -104,7 +104,6 @@ class NCGlobal: NSObject {
let nextcloudVersion26: Int = 26
let nextcloudVersion27: Int = 27
let nextcloudVersion28: Int = 28
let nextcloudVersion29: Int = 29
// Nextcloud unsupported
//
@ -473,6 +472,9 @@ class NCGlobal: NSObject {
@objc var capabilityUserStatusEnabled: Bool = false
var capabilityExternalSites: Bool = false
var capabilityGroupfoldersEnabled: Bool = false // NC27
var isLivePhotoServerAvailable: Bool { // NC28
return capabilityServerVersionMajor >= nextcloudVersion28
}
// MORE NEXTCLOUD APPS
let talkSchemeUrl = "nextcloudtalk://"

Просмотреть файл

@ -794,27 +794,30 @@ class NCNetworking: NSObject, NKCommonDelegate {
func uploadLivePhoto(metadata: tableMetadata) {
guard NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion28,
guard NCGlobal.shared.isLivePhotoServerAvailable,
metadata.isLivePhoto,
let metadata1 = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND urlBase == %@ AND path == %@ AND fileName == %@ AND status == %d", metadata.account, metadata.urlBase, metadata.path, metadata.livePhotoFile, NCGlobal.shared.metadataStatusNormal)) else {
return
}
let serverUrlfileNamePath = metadata.urlBase + metadata.path + metadata.livePhotoFile
let serverUrlfileNamePath1 = metadata1.urlBase + metadata1.path + metadata1.livePhotoFile
Task {
let results = await NextcloudKit.shared.setLivephoto(serverUrlfileNamePath: serverUrlfileNamePath, livePhotoFile: metadata1.livePhotoFile)
print("Send LivePhoto metadata error \(results.error.errorCode)")
let serverUrlfileNamePath = metadata.urlBase + metadata.path + metadata.livePhotoFile
var results = await NextcloudKit.shared.setLivephoto(serverUrlfileNamePath: serverUrlfileNamePath, livePhotoFile: metadata1.livePhotoFile)
if results.error == .success {
NCManageDatabase.shared.setMetadataLivePhotoByServer(account: metadata.account, ocId: metadata.ocId)
}
let results1 = await NextcloudKit.shared.setLivephoto(serverUrlfileNamePath: serverUrlfileNamePath1, livePhotoFile: metadata.livePhotoFile)
print("Send LivePhoto metadata1 error \(results1.error.errorCode)")
let serverUrlfileNamePath1 = metadata1.urlBase + metadata1.path + metadata1.livePhotoFile
results = await NextcloudKit.shared.setLivephoto(serverUrlfileNamePath: serverUrlfileNamePath1, livePhotoFile: metadata.livePhotoFile)
if results.error == .success {
NCManageDatabase.shared.setMetadataLivePhotoByServer(account: metadata1.account, ocId: metadata1.ocId)
}
}
}
func convertLivePhoto() {
guard NCGlobal.shared.capabilityServerVersionMajor >= NCGlobal.shared.nextcloudVersion28 else { return }
guard NCGlobal.shared.isLivePhotoServerAvailable else { return }
if let results = NCManageDatabase.shared.getResultsMetadatas(predicate: NSPredicate(format: "livePhotoServer == false AND livePhotoFile != ''")) {
var index: Int = 0
@ -823,7 +826,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
let serverUrlfileNamePath = result.urlBase + result.path + result.fileName
NextcloudKit.shared.setLivephoto(serverUrlfileNamePath: serverUrlfileNamePath, livePhotoFile: result.livePhotoFile) { _, error in
if error == .success {
NCManageDatabase.shared.setMetadataLivePhotoServer(account: result.account, ocId: result.ocId)
NCManageDatabase.shared.setMetadataLivePhotoByServer(account: result.account, ocId: result.ocId)
}
}
if index >= 20 { break }