summaryrefslogtreecommitdiff
path: root/src/BtCheckIntegrityEntry.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-05-03 11:00:39 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-05-03 11:00:39 +0000
commiteeece05063212ccf5b4f86cb7004739e2c3d5a94 (patch)
treec0b66275fa1a7e59b13feb19673f632d6791ffbc /src/BtCheckIntegrityEntry.cc
parentee229c6f00a0a01b99e37d91c14060a29d41a3a6 (diff)
2009-05-03 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that read-only file with wrong file size will cause error because it cannot be truncated to the correct size. Now if file size is different than the expected one, re-open file in writable mode. * src/AbstractSingleDiskAdaptor.cc * src/AbstractSingleDiskAdaptor.h * src/BtCheckIntegrityEntry.cc * src/DiskAdaptor.h * src/MultiDiskAdaptor.h * src/RequestGroup.cc
Diffstat (limited to 'src/BtCheckIntegrityEntry.cc')
-rw-r--r--src/BtCheckIntegrityEntry.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/BtCheckIntegrityEntry.cc b/src/BtCheckIntegrityEntry.cc
index 1be5e251..211467c2 100644
--- a/src/BtCheckIntegrityEntry.cc
+++ b/src/BtCheckIntegrityEntry.cc
@@ -51,11 +51,14 @@ BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {}
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();
-
+ const SharedHandle<DiskAdaptor>& diskAdaptor =
+ _requestGroup->getPieceStorage()->getDiskAdaptor();
+ if(diskAdaptor->isReadOnlyEnabled()) {
+ // Now reopen DiskAdaptor with read only disabled.
+ diskAdaptor->closeFile();
+ diskAdaptor->disableReadOnly();
+ diskAdaptor->openFile();
+ }
SharedHandle<BtFileAllocationEntry> entry
(new BtFileAllocationEntry(_requestGroup));
proceedFileAllocation(commands, entry, e);