diff options
author | Maxim Pimenov <m@maps.me> | 2019-03-13 15:21:49 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2019-03-18 18:42:54 +0300 |
commit | a4b6780b25ddc71d8909d1cefbfa4fff1b45e71b (patch) | |
tree | 92b12a9466a30cd10b1cc027875f891a09fd2cdb /storage | |
parent | e029c9f96105fb83b6a4cdc2ee647d094fb282b4 (diff) |
[storage] Delete the downloaded diff files when cancelled; better logging.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/diff_scheme/diff_manager.cpp | 9 | ||||
-rw-r--r-- | storage/storage.cpp | 7 |
2 files changed, 13 insertions, 3 deletions
diff --git a/storage/diff_scheme/diff_manager.cpp b/storage/diff_scheme/diff_manager.cpp index 492101539d..9e5746a135 100644 --- a/storage/diff_scheme/diff_manager.cpp +++ b/storage/diff_scheme/diff_manager.cpp @@ -94,7 +94,7 @@ void Manager::ApplyDiff(ApplyDiffParams && p, base::Cancellable const & cancella base::DeleteFileX(diffApplyingInProgressPath); if (result != DiffApplicationResult::Ok) - base::DeleteFileX(newMwmPath); + Platform::RemoveFileIfExists(newMwmPath); } switch (result) @@ -108,11 +108,14 @@ void Manager::ApplyDiff(ApplyDiffParams && p, base::Cancellable const & cancella it->second.m_status = SingleDiffStatus::Applied; break; } - case DiffApplicationResult::Cancelled: break; + case DiffApplicationResult::Cancelled: + // The diff file will be deleted by storage. + // Another way would be to leave it on disk but all consequences + // of interacting with storage are much harder to be taken into account that way. + break; case DiffApplicationResult::Failed: { diffFile->DeleteFromDisk(MapOptions::Diff); - alohalytics::Stats::Instance().LogEvent( "Downloader_DiffScheme_error", {{"type", "patching"}, diff --git a/storage/storage.cpp b/storage/storage.cpp index 28aca74b0b..efc04d7aa0 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -167,6 +167,7 @@ void Storage::DeleteAllLocalMaps(CountriesVec * existedCountries /* = nullptr */ existedCountries->push_back(localFiles.first); localFile->SyncWithDisk(); DeleteFromDiskWithIndexes(*localFile, MapOptions::MapWithCarRouting); + DeleteFromDiskWithIndexes(*localFile, MapOptions::Diff); } } } @@ -287,6 +288,7 @@ void Storage::RegisterAllLocalMaps(bool enableDiffs) LOG(LINFO, ("Removing obsolete", localFile)); localFile.SyncWithDisk(); DeleteFromDiskWithIndexes(localFile, MapOptions::MapWithCarRouting); + DeleteFromDiskWithIndexes(localFile, MapOptions::Diff); ++j; } @@ -582,6 +584,7 @@ void Storage::DeleteCustomCountryVersion(LocalCountryFile const & localFile) CountryFile const countryFile = localFile.GetCountryFile(); DeleteFromDiskWithIndexes(localFile, MapOptions::MapWithCarRouting); + DeleteFromDiskWithIndexes(localFile, MapOptions::Diff); { auto it = m_localFilesForFakeCountries.find(countryFile); @@ -1480,6 +1483,8 @@ void Storage::DownloadNode(CountryId const & countryId, bool isUpdate /* = false { CHECK_THREAD_CHECKER(m_threadChecker, ()); + LOG(LINFO, ("Downloading", countryId)); + CountryTreeNode const * const node = m_countries.FindFirst(countryId); if (!node) @@ -1920,6 +1925,8 @@ void Storage::CancelDownloadNode(CountryId const & countryId) { CHECK_THREAD_CHECKER(m_threadChecker, ()); + LOG(LINFO, ("Cancelling the downloading of", countryId)); + CountriesSet setQueue; GetQueuedCountries(m_queue, setQueue); |