mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
[ios] Remove fileCoordinator wrapping from downloading starting
And add check `isUbiquitousItem` before downloading start. This method returns false when the file doesn't exist. Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
0f2353aae6
commit
31104eed4d
@@ -39,20 +39,18 @@ final class SynchronizationFileWriter {
|
|||||||
|
|
||||||
// MARK: - Read/Write/Downloading/Uploading
|
// MARK: - Read/Write/Downloading/Uploading
|
||||||
private func startDownloading(_ cloudMetadataItem: CloudMetadataItem, completion: WritingResultCompletionHandler) {
|
private func startDownloading(_ cloudMetadataItem: CloudMetadataItem, completion: WritingResultCompletionHandler) {
|
||||||
var coordinationError: NSError?
|
LOG(.info, "Start downloading file: \(cloudMetadataItem.fileUrl.path)...")
|
||||||
fileCoordinator.coordinate(writingItemAt: cloudMetadataItem.fileUrl, options: [], error: &coordinationError) { cloudItemUrl in
|
|
||||||
do {
|
do {
|
||||||
LOG(.info, "Start downloading file: \(cloudItemUrl.path)...")
|
if fileManager.isUbiquitousItem(at: cloudMetadataItem.fileUrl) {
|
||||||
try fileManager.startDownloadingUbiquitousItem(at: cloudItemUrl)
|
try fileManager.startDownloadingUbiquitousItem(at: cloudMetadataItem.fileUrl)
|
||||||
|
} else {
|
||||||
|
LOG(.warning, "File \(cloudMetadataItem.fileUrl.path) is not a ubiquitous item. Skipping download.")
|
||||||
|
}
|
||||||
completion(.success)
|
completion(.success)
|
||||||
} catch {
|
} catch {
|
||||||
completion(.failure(error))
|
completion(.failure(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let coordinationError {
|
|
||||||
completion(.failure(coordinationError))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func createInLocalContainer(_ cloudMetadataItem: CloudMetadataItem, completion: @escaping WritingResultCompletionHandler) {
|
private func createInLocalContainer(_ cloudMetadataItem: CloudMetadataItem, completion: @escaping WritingResultCompletionHandler) {
|
||||||
let targetLocalFileUrl = cloudMetadataItem.relatedLocalItemUrl(to: localDirectoryUrl)
|
let targetLocalFileUrl = cloudMetadataItem.relatedLocalItemUrl(to: localDirectoryUrl)
|
||||||
|
|||||||
Reference in New Issue
Block a user