[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:
Kiryl Kaveryn
2025-07-23 18:38:36 +04:00
committed by Konstantin Pastbin
parent 0f2353aae6
commit 31104eed4d

View File

@@ -39,18 +39,16 @@ 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 { if fileManager.isUbiquitousItem(at: cloudMetadataItem.fileUrl) {
LOG(.info, "Start downloading file: \(cloudItemUrl.path)...") try fileManager.startDownloadingUbiquitousItem(at: cloudMetadataItem.fileUrl)
try fileManager.startDownloadingUbiquitousItem(at: cloudItemUrl) } else {
completion(.success) LOG(.warning, "File \(cloudMetadataItem.fileUrl.path) is not a ubiquitous item. Skipping download.")
} catch {
completion(.failure(error))
} }
} completion(.success)
if let coordinationError { } catch {
completion(.failure(coordinationError)) completion(.failure(error))
} }
} }