From c39b0879be928b8164e5a5686b69de17d711f861 Mon Sep 17 00:00:00 2001 From: Anton Yarmolenko Date: Tue, 11 Jun 2024 10:44:22 +0200 Subject: [PATCH] fix: delete local file first since we build url with data from DB (#453) Co-authored-by: Anton Yarmolenko <37253+rnr@users.noreply.github.com> --- Core/Core/Network/DownloadManager.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Core/Network/DownloadManager.swift b/Core/Core/Network/DownloadManager.swift index 15ec5fd10..1ef8bcb3a 100644 --- a/Core/Core/Network/DownloadManager.swift +++ b/Core/Core/Network/DownloadManager.swift @@ -274,11 +274,11 @@ public class DownloadManager: DownloadManagerProtocol { public func deleteFile(blocks: [CourseBlock]) async { for block in blocks { do { - try persistence.deleteDownloadDataTask(id: block.id) - currentDownloadEventPublisher.send(.deletedFile(block.id)) if let fileURL = await fileUrl(for: block.id) { try FileManager.default.removeItem(at: fileURL) } + try persistence.deleteDownloadDataTask(id: block.id) + currentDownloadEventPublisher.send(.deletedFile(block.id)) } catch { debugLog("Error deleting file: \(error.localizedDescription)") }