diff options
author | marinofaggiana <marino@marinofaggiana.com> | 2020-07-21 15:56:07 +0300 |
---|---|---|
committer | marinofaggiana <marino@marinofaggiana.com> | 2020-07-21 15:56:07 +0300 |
commit | 1944e3f24bc905d29fa4f2300c9a9531e554f31a (patch) | |
tree | e2145947dfea66760bf9e02be59f23823d7ede2e /File Provider Extension | |
parent | 0a6d204543b418829652caed2d963b9fec4ad305 (diff) |
coding
Diffstat (limited to 'File Provider Extension')
-rw-r--r-- | File Provider Extension/FileProviderExtension+Actions.swift | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index b1aa84fba..f59d79395 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -230,6 +230,8 @@ extension FileProviderExtension { } var favorite = false + let ocId = metadata.ocId + if favoriteRank == nil { fileProviderData.sharedInstance.listFavoriteIdentifierRank.removeValue(forKey: itemIdentifier.rawValue) } else { @@ -244,17 +246,32 @@ extension FileProviderExtension { let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: fileProviderData.sharedInstance.accountUrl)! NCCommunication.shared.setFavorite(fileName: fileNamePath, favorite: favorite) { (account, errorCode, errorDescription) in + if errorCode == 0 { + + guard let metadataTemp = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", ocId)) else { + completionHandler(nil, NSFileProviderError(.noSuchItem)) + return + } + let metadata = tableMetadata.init(value: metadataTemp) + // Change DB metadata.favorite = favorite NCManageDatabase.sharedInstance.addMetadata(metadata) - let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier) + let item = FileProviderItem(metadata: metadata.freeze(), parentItemIdentifier: parentItemIdentifier) fileProviderData.sharedInstance.fileProviderSignalUpdateWorkingSetItem[item.itemIdentifier] = item fileProviderData.sharedInstance.signalEnumerator(for: [.workingSet]) completionHandler(item, nil) + } else { + + guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", ocId)) else { + completionHandler(nil, NSFileProviderError(.noSuchItem)) + return + } + // Errore, remove from listFavoriteIdentifierRank fileProviderData.sharedInstance.listFavoriteIdentifierRank.removeValue(forKey: itemIdentifier.rawValue) let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier) |