mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +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,18 +39,16 @@ final class SynchronizationFileWriter {
|
||||
|
||||
// MARK: - Read/Write/Downloading/Uploading
|
||||
private func startDownloading(_ cloudMetadataItem: CloudMetadataItem, completion: WritingResultCompletionHandler) {
|
||||
var coordinationError: NSError?
|
||||
fileCoordinator.coordinate(writingItemAt: cloudMetadataItem.fileUrl, options: [], error: &coordinationError) { cloudItemUrl in
|
||||
do {
|
||||
LOG(.info, "Start downloading file: \(cloudItemUrl.path)...")
|
||||
try fileManager.startDownloadingUbiquitousItem(at: cloudItemUrl)
|
||||
completion(.success)
|
||||
} catch {
|
||||
completion(.failure(error))
|
||||
LOG(.info, "Start downloading file: \(cloudMetadataItem.fileUrl.path)...")
|
||||
do {
|
||||
if fileManager.isUbiquitousItem(at: cloudMetadataItem.fileUrl) {
|
||||
try fileManager.startDownloadingUbiquitousItem(at: cloudMetadataItem.fileUrl)
|
||||
} else {
|
||||
LOG(.warning, "File \(cloudMetadataItem.fileUrl.path) is not a ubiquitous item. Skipping download.")
|
||||
}
|
||||
}
|
||||
if let coordinationError {
|
||||
completion(.failure(coordinationError))
|
||||
completion(.success)
|
||||
} catch {
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user