Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ios/Classes/OfflineManagerUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class OfflineManagerUtils {
}
})
if let packToRemoveUnwrapped = packToRemove {
// deletion is only safe if the download is suspended
packToRemoveUnwrapped.suspend()
OfflineManagerUtils.releaseDownloader(id: id)

offlineStorage.removePack(packToRemoveUnwrapped) { error in
if let error = error {
result(FlutterError(
Expand Down
4 changes: 1 addition & 3 deletions ios/Classes/OfflinePackDownloadManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class OfflinePackDownloader {
))
if let region = OfflineRegion.fromOfflinePack(pack) {
OfflineManagerUtils.deleteRegion(result: result, id: region.id)
OfflineManagerUtils.releaseDownloader(id:region.id)
}
}

Expand All @@ -158,7 +157,6 @@ class OfflinePackDownloader {
))
if let region = OfflineRegion.fromOfflinePack(pack) {
OfflineManagerUtils.deleteRegion(result: result, id: region.id)
OfflineManagerUtils.releaseDownloader(id: region.id)
}
}

Expand Down Expand Up @@ -193,7 +191,7 @@ class OfflinePackDownloader {
return false
}
// We can tell whether 2 packs are the same by comparing metadata we assigned earlier
return pack.context == currentlyManagedPack.context
return pack.state != .invalid && pack.context == currentlyManagedPack.context
}

private func calculateDownloadingProgress(
Expand Down