From 3974c1223b19a8647d7e361fa130d0fa78a41026 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 12 Nov 2015 22:42:24 +0900 Subject: 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 --- src/BtFileAllocationEntry.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/BtFileAllocationEntry.cc') 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>& 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()) { -- cgit