diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-11-12 22:42:24 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-11-12 22:42:24 +0900 |
| commit | 3974c1223b19a8647d7e361fa130d0fa78a41026 (patch) | |
| tree | 4cd9f9585cb2939ecef37a3d215ab59f4df6f751 /src/StreamFileAllocationEntry.cc | |
| parent | af98861aff50737f87d9c251ee9a68280bba3e64 (diff) | |
Don't enable mmap if file allocation is disabled
Without file allocation, we cannot map file because file length could
be zero.
This could fix bug reported at GH-478
Diffstat (limited to 'src/StreamFileAllocationEntry.cc')
| -rw-r--r-- | src/StreamFileAllocationEntry.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc index dfe1f679..de851da6 100644 --- a/src/StreamFileAllocationEntry.cc +++ b/src/StreamFileAllocationEntry.cc @@ -60,10 +60,13 @@ void StreamFileAllocationEntry::prepareForNextAction (std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e) { + auto &option = getRequestGroup()->getOption(); + // For DownloadContext::resetDownloadStartTime(), see also // RequestGroup::createInitialCommand() getRequestGroup()->getDownloadContext()->resetDownloadStartTime(); - if(getRequestGroup()->getOption()->getAsBool(PREF_ENABLE_MMAP)) { + if(option->getAsBool(PREF_ENABLE_MMAP) && + option->get(PREF_FILE_ALLOCATION) != V_NONE) { getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableMmap(); } if(getNextCommand()) { |
