summaryrefslogtreecommitdiff
path: root/src/BtFileAllocationEntry.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-03-26 17:12:52 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-03-26 17:20:27 +0900
commitd64089632e82a2548752c7a6baaa68365a795a74 (patch)
tree57fc7b85a8c1290975d58fa4761b04a7695bf7e3 /src/BtFileAllocationEntry.cc
parentc81b1321122e8509b55c94c0cbca0d8d6d319f0c (diff)
parenta7cd943a06b1a5ff4515b57060b84037f8d01f9f (diff)
Merge branch 'master' into random-webseeding
Diffstat (limited to 'src/BtFileAllocationEntry.cc')
-rw-r--r--src/BtFileAllocationEntry.cc37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/BtFileAllocationEntry.cc b/src/BtFileAllocationEntry.cc
index 44553354..dc9cc04f 100644
--- a/src/BtFileAllocationEntry.cc
+++ b/src/BtFileAllocationEntry.cc
@@ -50,34 +50,41 @@
namespace aria2 {
-BtFileAllocationEntry::BtFileAllocationEntry(RequestGroup* requestGroup):
- FileAllocationEntry(requestGroup, nullptr) {}
+BtFileAllocationEntry::BtFileAllocationEntry(RequestGroup* requestGroup)
+ : FileAllocationEntry(requestGroup, nullptr)
+{
+}
BtFileAllocationEntry::~BtFileAllocationEntry() {}
-void BtFileAllocationEntry::prepareForNextAction
-(std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e)
+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()->size() <=
+ option->getAsLLInt(PREF_MAX_MMAP_LIMIT)) {
getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableMmap();
}
- if(!getRequestGroup()->downloadFinished()) {
+ if (!getRequestGroup()->downloadFinished()) {
// For DownloadContext::resetDownloadStartTime(), see also
// RequestGroup::createInitialCommand()
getRequestGroup()->getDownloadContext()->resetDownloadStartTime();
- const std::vector<std::shared_ptr<FileEntry> >& fileEntries =
- getRequestGroup()->getDownloadContext()->getFileEntries();
- if(isUriSuppliedForRequsetFileEntry
- (std::begin(fileEntries), std::end(fileEntries))) {
+ const std::vector<std::shared_ptr<FileEntry>>& fileEntries =
+ getRequestGroup()->getDownloadContext()->getFileEntries();
+ if (isUriSuppliedForRequsetFileEntry(std::begin(fileEntries),
+ std::end(fileEntries))) {
getRequestGroup()->createNextCommandWithAdj(commands, e, 0);
}
- } else {
+ }
+ else {
#ifdef __MINGW32__
const std::shared_ptr<DiskAdaptor>& diskAdaptor =
- getRequestGroup()->getPieceStorage()->getDiskAdaptor();
- if(!diskAdaptor->isReadOnlyEnabled()) {
+ getRequestGroup()->getPieceStorage()->getDiskAdaptor();
+ if (!diskAdaptor->isReadOnlyEnabled()) {
// On Windows, if aria2 opens files with GENERIC_WRITE access
// right, some programs cannot open them aria2 is seeding. To
// avoid this situation, re-open the files with read-only