Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2011-12-05 19:10:15 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:29:37 +0300
commit40ed40cdf9a52651d39dbd406b729a6fd1675a1c (patch)
tree60c01561fb485e25a480ee7278d308cb5f0f31cc /platform/http_request.cpp
parent1b74903e669c43af4d1f41928af8c7613122c852 (diff)
[downloader] Fixed ".resume" file creation/destruction while downloading
Diffstat (limited to 'platform/http_request.cpp')
-rw-r--r--platform/http_request.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/platform/http_request.cpp b/platform/http_request.cpp
index 33792d7f9f..de65a4b048 100644
--- a/platform/http_request.cpp
+++ b/platform/http_request.cpp
@@ -151,7 +151,7 @@ class FileHttpRequest : public HttpRequest, public IHttpThreadCallback
if (isChunkOk)
{ // save information for download resume
++m_goodChunksCount;
- if (m_goodChunksCount % 10)
+ if (m_status != ECompleted && m_goodChunksCount % 10 == 0)
SaveRanges(m_filePath + ".resume", m_strategy.ChunksLeft());
}
@@ -189,8 +189,14 @@ class FileHttpRequest : public HttpRequest, public IHttpThreadCallback
static void SaveRanges(string const & file, ChunksDownloadStrategy::RangesContainerT const & ranges)
{
- FileWriterStream fws(file);
- fws << ranges;
+ // Delete resume file if ranges are empty
+ if (ranges.empty())
+ FileWriter::DeleteFileX(file);
+ else
+ {
+ FileWriterStream fws(file);
+ fws << ranges;
+ }
}
struct CalcRanges