forked from organicmaps/organicmaps-tmp
[storage] Fixed a crash.
Consider the following scenario. 1. Diffs for A and B are downloaded but not applied. Currently it is possible because we do not delete a diff whose application process was cancelled. 2. The update button is clicked for both A and B, adding them both to the queue. 3. The cancel button is clicked for both A and B. The cancellation of A sends a signal to the diff manager and kicks the downloader to start applying B. The diff manager receives the signal to cancel A and resets the m_latestDiffRequest. Then, the cancel request to B clears the queue but never reaches the diff manager (because of the m_latestDiffRequest mismatch), and, once the diff to B has been successfully applied, Storage cannot remove B from queue because it has already been removed.
This commit is contained in:
parent
42294122d9
commit
21fc72fc0d
1 changed files with 14 additions and 4 deletions
|
@ -700,6 +700,12 @@ void Storage::DownloadNextFile(QueuedCountry const & country)
|
|||
// switch to next file.
|
||||
if (isDownloadedDiff || p.GetFileSizeByFullPath(readyFilePath, size))
|
||||
{
|
||||
if (m_latestDiffRequest)
|
||||
{
|
||||
// No need to kick the downloader: it will be kicked by
|
||||
// the current diff application process when it is completed or cancelled.
|
||||
return;
|
||||
}
|
||||
OnMapFileDownloadFinished(HttpRequest::Status::Completed,
|
||||
MapFilesDownloader::Progress(size, size));
|
||||
return;
|
||||
|
@ -1600,14 +1606,18 @@ void Storage::ApplyDiff(CountryId const & countryId, function<void(bool isSucces
|
|||
RegisterCountryFiles(diffFile);
|
||||
Platform::DisableBackupForFile(diffFile->GetPath(MapOptions::Map));
|
||||
fn(true);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DiffApplicationResult::Cancelled:
|
||||
{
|
||||
CHECK(!IsDiffApplyingInProgressToCountry(countryId), ());
|
||||
DownloadNextCountryFromQueue();
|
||||
break;
|
||||
}
|
||||
case DiffApplicationResult::Failed:
|
||||
{
|
||||
fn(false);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DiffApplicationResult::Failed: fn(false); break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue