Properly write item metadata status update to database in NextcloudFilesDatabaseManager

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-14 14:22:28 +01:00
parent 017de893f0
commit 2ca2609e0c
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -225,8 +225,12 @@ class NextcloudFilesDatabaseManager : NSObject {
do {
try database.write {
result = database.objects(NextcloudItemMetadataTable.self).filter("ocId == %@", metadata.ocId).first
result?.status = status.rawValue
guard let result = database.objects(NextcloudItemMetadataTable.self).filter("ocId == %@", metadata.ocId).first else {
return
}
result.status = status.rawValue
database.add(result, update: .all)
}
} catch let error {
NSLog("Could not update status for item metadata with ocID: %@ and filename: %@, received error: %@", metadata.ocId, metadata.fileNameView, error.localizedDescription)