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/BtFileAllocationEntry.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/BtFileAllocationEntry.cc')
| -rw-r--r-- | src/BtFileAllocationEntry.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/BtFileAllocationEntry.cc b/src/BtFileAllocationEntry.cc index 44553354..89a4c7c4 100644 --- a/src/BtFileAllocationEntry.cc +++ b/src/BtFileAllocationEntry.cc @@ -58,9 +58,11 @@ BtFileAllocationEntry::~BtFileAllocationEntry() {} void BtFileAllocationEntry::prepareForNextAction (std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e) { - BtSetup().setup(commands, getRequestGroup(), e, - getRequestGroup()->getOption().get()); - if(getRequestGroup()->getOption()->getAsBool(PREF_ENABLE_MMAP)) { + auto &option = getRequestGroup()->getOption(); + + BtSetup().setup(commands, getRequestGroup(), e, option.get()); + if(option->getAsBool(PREF_ENABLE_MMAP) && + option->get(PREF_FILE_ALLOCATION) != V_NONE) { getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableMmap(); } if(!getRequestGroup()->downloadFinished()) { |
