summaryrefslogtreecommitdiff
path: root/src/BtCheckIntegrityEntry.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-02-23 13:27:08 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-02-23 13:27:08 +0000
commit2dfee3dc49463286854aa3e20ab0398b3c8adb57 (patch)
treee7e2624664ad717a62776136e80bc858d93e309c /src/BtCheckIntegrityEntry.cc
parent120e2de09646b200a78e971d24b061a1d9e47b67 (diff)
2009-02-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
In BitTorrent, Open files in read-only mode for hash check. After that, re-open file in read/write mode only when the download is not finished. * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/AbstractSingleDiskAdaptor.cc * src/AbstractSingleDiskAdaptor.h * src/BtCheckIntegrityEntry.cc * src/DiskAdaptor.h * src/DiskWriter.h * src/MultiDiskAdaptor.cc * src/MultiDiskAdaptor.h * src/RequestGroup.cc
Diffstat (limited to 'src/BtCheckIntegrityEntry.cc')
-rw-r--r--src/BtCheckIntegrityEntry.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/BtCheckIntegrityEntry.cc b/src/BtCheckIntegrityEntry.cc
index feeb924e..bed582c5 100644
--- a/src/BtCheckIntegrityEntry.cc
+++ b/src/BtCheckIntegrityEntry.cc
@@ -49,17 +49,28 @@ BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup):
BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {}
-void BtCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& commands,
- DownloadEngine* e)
+static void proceedFileAllocation
+(std::deque<Command*>& commands, DownloadEngine* e, RequestGroup* requestGroup)
{
- FileAllocationEntryHandle entry(new BtFileAllocationEntry(_requestGroup));
- if(_requestGroup->needsFileAllocation()) {
+ FileAllocationEntryHandle entry(new BtFileAllocationEntry(requestGroup));
+ if(requestGroup->needsFileAllocation()) {
e->_fileAllocationMan->pushEntry(entry);
} else {
entry->prepareForNextAction(commands, e);
}
}
+void BtCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& commands,
+ DownloadEngine* e)
+{
+ // Now reopen DiskAdaptor with read only disabled.
+ _requestGroup->getPieceStorage()->getDiskAdaptor()->closeFile();
+ _requestGroup->getPieceStorage()->getDiskAdaptor()->disableReadOnly();
+ _requestGroup->getPieceStorage()->getDiskAdaptor()->openFile();
+
+ proceedFileAllocation(commands, e, _requestGroup);
+}
+
void BtCheckIntegrityEntry::onDownloadFinished(std::deque<Command*>& commands,
DownloadEngine* e)
{
@@ -69,8 +80,9 @@ void BtCheckIntegrityEntry::onDownloadFinished(std::deque<Command*>& commands,
// to exit rather than doing seeding. So, it would be good to toggle this
// behavior.
if(e->option->getAsBool(PREF_BT_HASH_CHECK_SEED)) {
- onDownloadIncomplete(commands, e);
+ proceedFileAllocation(commands, e, _requestGroup);
}
}
+
} // namespace aria2