diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2011-11-09 20:09:35 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:27:32 +0300 |
commit | 2dc0ca689c0ea24b5e8b28e89cabbf2bbe945fb5 (patch) | |
tree | fb7499f1538ce1e32e237456d247d1d75abef9ab /platform/chunks_download_strategy.cpp | |
parent | 710aa71023fe23a8b7f3d7f2e578438155eee15c (diff) |
[downloader] Added resume support for chunked downloads
Diffstat (limited to 'platform/chunks_download_strategy.cpp')
-rw-r--r-- | platform/chunks_download_strategy.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/platform/chunks_download_strategy.cpp b/platform/chunks_download_strategy.cpp index ff22ab3f1b..88ead660a8 100644 --- a/platform/chunks_download_strategy.cpp +++ b/platform/chunks_download_strategy.cpp @@ -10,7 +10,8 @@ namespace downloader ChunksDownloadStrategy::RangeT const ChunksDownloadStrategy::INVALID_RANGE = RangeT(-1, -1); -ChunksDownloadStrategy::ChunksDownloadStrategy(vector<string> const & urls, int64_t fileSize, int64_t chunkSize) +ChunksDownloadStrategy::ChunksDownloadStrategy(vector<string> const & urls, int64_t fileSize, + int64_t chunkSize) : m_chunkSize(chunkSize) { // init servers list @@ -18,12 +19,13 @@ ChunksDownloadStrategy::ChunksDownloadStrategy(vector<string> const & urls, int6 m_servers.push_back(make_pair(urls[i], INVALID_RANGE)); // init chunks which should be downloaded - // @TODO implement download resume by saving chunks to download for specified file for (int64_t i = 0; i < fileSize; i += chunkSize) - { - m_chunksToDownload.insert(RangeT(i, min(i + chunkSize - 1, - fileSize - 1))); - } + m_chunksToDownload.insert(RangeT(i, min(i + chunkSize - 1, fileSize - 1))); +} + +void ChunksDownloadStrategy::SetChunksToDownload(RangesContainerT & chunks) +{ + m_chunksToDownload.swap(chunks); } void ChunksDownloadStrategy::ChunkFinished(bool successfully, int64_t begRange, int64_t endRange) |