/* */ #include "BtCheckIntegrityEntry.h" #include "BtFileAllocationEntry.h" #include "RequestGroup.h" #include "PieceStorage.h" #include "DownloadEngine.h" #include "DiskAdaptor.h" #include "prefs.h" #include "Option.h" namespace aria2 { BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup): PieceHashCheckIntegrityEntry(requestGroup, 0) {} BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {} void BtCheckIntegrityEntry::onDownloadIncomplete (std::vector& commands, DownloadEngine* e) { if(getRequestGroup()->getOption()->getAsBool(PREF_HASH_CHECK_ONLY)) { return; } const SharedHandle& diskAdaptor = getRequestGroup()->getPieceStorage()->getDiskAdaptor(); if(diskAdaptor->isReadOnlyEnabled()) { // Now reopen DiskAdaptor with read only disabled. diskAdaptor->closeFile(); diskAdaptor->disableReadOnly(); diskAdaptor->openFile(); } SharedHandle entry (new BtFileAllocationEntry(getRequestGroup())); proceedFileAllocation(commands, entry, e); } void BtCheckIntegrityEntry::onDownloadFinished (std::vector& commands, DownloadEngine* e) { // TODO Currently,when all the checksums // are valid, then aira2 goes to seeding mode. Sometimes it is better // to exit rather than doing seeding. So, it would be good to toggle this // behavior. if(!getRequestGroup()->getOption()->getAsBool(PREF_HASH_CHECK_ONLY) && getRequestGroup()->getOption()->getAsBool(PREF_BT_HASH_CHECK_SEED)) { SharedHandle entry (new BtFileAllocationEntry(getRequestGroup())); proceedFileAllocation(commands, entry, e); } } } // namespace aria2