diff options
author | marinofaggiana <marino@marinofaggiana.com> | 2020-07-14 11:15:49 +0300 |
---|---|---|
committer | marinofaggiana <marino@marinofaggiana.com> | 2020-07-14 11:15:49 +0300 |
commit | 09ae8cf850c99d83c2e9b87dd6d8a3cbe56a5881 (patch) | |
tree | 6fa7f127d746528912d8869bfaabf9394650c1df /File Provider Extension | |
parent | 2dd7fa7f323260fbd74877d079350c5d5fdd3323 (diff) |
coding
Diffstat (limited to 'File Provider Extension')
3 files changed, 13 insertions, 22 deletions
diff --git a/File Provider Extension/FileProviderExtension+Actions.swift b/File Provider Extension/FileProviderExtension+Actions.swift index 3f16aa443..acc5d11a7 100644 --- a/File Provider Extension/FileProviderExtension+Actions.swift +++ b/File Provider Extension/FileProviderExtension+Actions.swift @@ -51,22 +51,19 @@ extension FileProviderExtension { metadata.serverUrl = tableDirectory.serverUrl metadata.typeFile = k_metadataTypeFile_directory - guard let metadataUpdate = NCManageDatabase.sharedInstance.addMetadata(metadata) else { - completionHandler(nil, NSFileProviderError(.noSuchItem)) - return - } + NCManageDatabase.sharedInstance.addMetadata(metadata) guard let _ = NCManageDatabase.sharedInstance.addDirectory(encrypted: false, favorite: false, ocId: ocId!, fileId: "", etag: nil, permissions: nil, serverUrl: tableDirectory.serverUrl + "/" + directoryName, richWorkspace: nil, account: account) else { completionHandler(nil, NSFileProviderError(.noSuchItem)) return } - guard let parentItemIdentifier = fileProviderUtility.sharedInstance.getParentItemIdentifier(metadata: metadataUpdate, homeServerUrl: fileProviderData.sharedInstance.homeServerUrl) else { + guard let parentItemIdentifier = fileProviderUtility.sharedInstance.getParentItemIdentifier(metadata: metadata, homeServerUrl: fileProviderData.sharedInstance.homeServerUrl) else { completionHandler(nil, NSFileProviderError(.noSuchItem)) return } - let item = FileProviderItem(metadata: metadataUpdate, parentItemIdentifier: parentItemIdentifier) + let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier) completionHandler(item, nil) } else { @@ -247,11 +244,8 @@ extension FileProviderExtension { if errorCode == 0 { // Change DB metadata.favorite = favorite - guard let metadataUpdate = NCManageDatabase.sharedInstance.addMetadata(metadata) else { - completionHandler(nil, NSFileProviderError(.noSuchItem)) - return - } - let item = FileProviderItem(metadata: metadataUpdate, parentItemIdentifier: parentItemIdentifier) + NCManageDatabase.sharedInstance.addMetadata(metadata) + let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier) fileProviderData.sharedInstance.fileProviderSignalUpdateWorkingSetItem[item.itemIdentifier] = item fileProviderData.sharedInstance.signalEnumerator(for: [.workingSet]) diff --git a/File Provider Extension/FileProviderExtension+NetworkingDelegate.swift b/File Provider Extension/FileProviderExtension+NetworkingDelegate.swift index 2b20e82c1..067058134 100644 --- a/File Provider Extension/FileProviderExtension+NetworkingDelegate.swift +++ b/File Provider Extension/FileProviderExtension+NetworkingDelegate.swift @@ -61,8 +61,8 @@ extension FileProviderExtension: NCNetworkingDelegate { metadata.size = Double(size) metadata.status = Int(k_metadataStatusNormal) - guard let metadataUpdated = NCManageDatabase.sharedInstance.addMetadata(metadata) else { return } - _ = NCManageDatabase.sharedInstance.addLocalFile(metadata: metadataUpdated) + NCManageDatabase.sharedInstance.addMetadata(metadata) + NCManageDatabase.sharedInstance.addLocalFile(metadata: metadata) // New file if ocId != ocIdTemp { @@ -76,7 +76,7 @@ extension FileProviderExtension: NCNetworkingDelegate { } // Signal update - item = FileProviderItem(metadata: metadataUpdated, parentItemIdentifier: parentItemIdentifier) + item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier) fileProviderData.sharedInstance.fileProviderSignalUpdateContainerItem[item.itemIdentifier] = item fileProviderData.sharedInstance.fileProviderSignalUpdateWorkingSetItem[item.itemIdentifier] = item fileProviderData.sharedInstance.signalEnumerator(for: [parentItemIdentifier, .workingSet]) diff --git a/File Provider Extension/FileProviderExtension.swift b/File Provider Extension/FileProviderExtension.swift index e4b974444..d668e084e 100644 --- a/File Provider Extension/FileProviderExtension.swift +++ b/File Provider Extension/FileProviderExtension.swift @@ -216,7 +216,7 @@ class FileProviderExtension: NSFileProviderExtension { return } - guard var metadata = fileProviderUtility.sharedInstance.getTableMetadataFromItemIdentifier(identifier) else { + guard let metadata = fileProviderUtility.sharedInstance.getTableMetadataFromItemIdentifier(identifier) else { completionHandler(NSFileProviderError(.noSuchItem)) return } @@ -232,7 +232,7 @@ class FileProviderExtension: NSFileProviderExtension { NCCommunication.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { (request) in metadata.status = Int(k_metadataStatusDownloading) - if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result } + NCManageDatabase.sharedInstance.addMetadata(metadata) downloadRequest = request self.outstandingSessionTasks[url] = task @@ -255,7 +255,7 @@ class FileProviderExtension: NSFileProviderExtension { metadata.etag = etag ?? "" NCManageDatabase.sharedInstance.addLocalFile(metadata: metadata) - if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result } + NCManageDatabase.sharedInstance.addMetadata(metadata) completionHandler(nil) @@ -366,10 +366,7 @@ class FileProviderExtension: NSFileProviderExtension { metadata.size = size metadata.status = Int(k_metadataStatusInUpload) - guard let metadataForUpload = NCManageDatabase.sharedInstance.addMetadata(metadata) else { - completionHandler(nil, NSFileProviderError(.noSuchItem)) - return - } + NCManageDatabase.sharedInstance.addMetadata(metadata) let serverUrlFileName = tableDirectory.serverUrl + "/" + fileName let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName)! @@ -379,7 +376,7 @@ class FileProviderExtension: NSFileProviderExtension { NSFileProviderManager.default.register(task, forItemWithIdentifier: NSFileProviderItemIdentifier(ocIdTemp)) { (error) in } } - let item = FileProviderItem(metadata: metadataForUpload, parentItemIdentifier: parentItemIdentifier) + let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier) completionHandler(item, nil) } } |