mirror of https://github.com/aria2/aria2
2009-10-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Don't save control file when aria2 exists while checking piece hash(behavior of -V option). If control file doesn't exist when aria2 launched, the completed length in saved control file will be 0 byte and this confuses user. disableSaveControlFile() is called in RequestGroup::processCheckIntegrityEntry(). enableSaveControlFile() will be called after hash checking is done. See CheckIntegrityCommand. * src/CheckIntegrityCommand.cc * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.ccpull/1/head
parent
436448dd8a
commit
5f1d8c7897
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2009-10-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Don't save control file when aria2 exists while checking piece
|
||||||
|
hash(behavior of -V option). If control file doesn't exist when
|
||||||
|
aria2 launched, the completed length in saved control file will be
|
||||||
|
0 byte and this confuses user. disableSaveControlFile() is called
|
||||||
|
in RequestGroup::processCheckIntegrityEntry().
|
||||||
|
enableSaveControlFile() will be called after hash checking is
|
||||||
|
done. See CheckIntegrityCommand.
|
||||||
|
* src/CheckIntegrityCommand.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* src/RequestGroup.h
|
||||||
|
* src/RequestGroupMan.cc
|
||||||
|
|
||||||
2009-10-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-10-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Included version number in Peer ID and client version. Peer ID
|
Included version number in Peer ID and client version. Peer ID
|
||||||
|
|
|
@ -60,7 +60,10 @@ bool CheckIntegrityCommand::executeInternal()
|
||||||
_entry->validateChunk();
|
_entry->validateChunk();
|
||||||
if(_entry->finished()) {
|
if(_entry->finished()) {
|
||||||
_e->_checkIntegrityMan->dropPickedEntry();
|
_e->_checkIntegrityMan->dropPickedEntry();
|
||||||
|
// Enable control file saving here. See also
|
||||||
|
// RequestGroup::processCheckIntegrityEntry() to know why this is
|
||||||
|
// needed.
|
||||||
|
_requestGroup->enableSaveControlFile();
|
||||||
if(_requestGroup->downloadFinished()) {
|
if(_requestGroup->downloadFinished()) {
|
||||||
logger->notice(MSG_VERIFICATION_SUCCESSFUL,
|
logger->notice(MSG_VERIFICATION_SUCCESSFUL,
|
||||||
_requestGroup->getDownloadContext()->getBasePath().c_str());
|
_requestGroup->getDownloadContext()->getBasePath().c_str());
|
||||||
|
|
|
@ -118,6 +118,7 @@ RequestGroup::RequestGroup(const SharedHandle<Option>& option):
|
||||||
_numStreamConnection(0),
|
_numStreamConnection(0),
|
||||||
_numCommand(0),
|
_numCommand(0),
|
||||||
_segmentManFactory(new DefaultSegmentManFactory(_option.get())),
|
_segmentManFactory(new DefaultSegmentManFactory(_option.get())),
|
||||||
|
_saveControlFile(true),
|
||||||
_progressInfoFile(new NullProgressInfoFile()),
|
_progressInfoFile(new NullProgressInfoFile()),
|
||||||
_preLocalFileCheckEnabled(true),
|
_preLocalFileCheckEnabled(true),
|
||||||
_haltRequested(false),
|
_haltRequested(false),
|
||||||
|
@ -394,6 +395,13 @@ void RequestGroup::processCheckIntegrityEntry(std::deque<Command*>& commands,
|
||||||
entry->isValidationReady()) {
|
entry->isValidationReady()) {
|
||||||
entry->initValidator();
|
entry->initValidator();
|
||||||
entry->cutTrailingGarbage();
|
entry->cutTrailingGarbage();
|
||||||
|
// Don't save control file(.aria2 file) when user presses
|
||||||
|
// control-c key while aria2 is checking hashes. If control file
|
||||||
|
// doesn't exist when aria2 launched, the completed length in
|
||||||
|
// saved control file will be 0 byte and this confuses user.
|
||||||
|
// enableSaveControlFile() will be called after hash checking is
|
||||||
|
// done. See CheckIntegrityCommand.
|
||||||
|
disableSaveControlFile();
|
||||||
e->_checkIntegrityMan->pushEntry(entry);
|
e->_checkIntegrityMan->pushEntry(entry);
|
||||||
} else
|
} else
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
@ -1018,4 +1026,16 @@ void RequestGroup::setLastUriResult
|
||||||
_lastUriResult.reset(new URIResult(uri, result));
|
_lastUriResult.reset(new URIResult(uri, result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RequestGroup::saveControlFile() const
|
||||||
|
{
|
||||||
|
if(_saveControlFile) {
|
||||||
|
_progressInfoFile->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RequestGroup::removeControlFile() const
|
||||||
|
{
|
||||||
|
_progressInfoFile->removeFile();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -102,6 +102,8 @@ private:
|
||||||
|
|
||||||
SharedHandle<PieceStorage> _pieceStorage;
|
SharedHandle<PieceStorage> _pieceStorage;
|
||||||
|
|
||||||
|
bool _saveControlFile;
|
||||||
|
|
||||||
SharedHandle<BtProgressInfoFile> _progressInfoFile;
|
SharedHandle<BtProgressInfoFile> _progressInfoFile;
|
||||||
|
|
||||||
SharedHandle<DiskWriterFactory> _diskWriterFactory;
|
SharedHandle<DiskWriterFactory> _diskWriterFactory;
|
||||||
|
@ -253,11 +255,6 @@ public:
|
||||||
|
|
||||||
void setPieceStorage(const SharedHandle<PieceStorage>& pieceStorage);
|
void setPieceStorage(const SharedHandle<PieceStorage>& pieceStorage);
|
||||||
|
|
||||||
const SharedHandle<BtProgressInfoFile>& getProgressInfoFile() const
|
|
||||||
{
|
|
||||||
return _progressInfoFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setProgressInfoFile(const SharedHandle<BtProgressInfoFile>& progressInfoFile);
|
void setProgressInfoFile(const SharedHandle<BtProgressInfoFile>& progressInfoFile);
|
||||||
|
|
||||||
void increaseStreamConnection();
|
void increaseStreamConnection();
|
||||||
|
@ -440,6 +437,14 @@ public:
|
||||||
|
|
||||||
void setLastUriResult(std::string uri, downloadresultcode::RESULT result);
|
void setLastUriResult(std::string uri, downloadresultcode::RESULT result);
|
||||||
|
|
||||||
|
void saveControlFile() const;
|
||||||
|
|
||||||
|
void removeControlFile() const;
|
||||||
|
|
||||||
|
void enableSaveControlFile() { _saveControlFile = true; }
|
||||||
|
|
||||||
|
void disableSaveControlFile() { _saveControlFile = false; }
|
||||||
|
|
||||||
static void resetGIDCounter() { _gidCounter = 0; }
|
static void resetGIDCounter() { _gidCounter = 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -301,10 +301,10 @@ public:
|
||||||
group->applyLastModifiedTimeToLocalFiles();
|
group->applyLastModifiedTimeToLocalFiles();
|
||||||
group->reportDownloadFinished();
|
group->reportDownloadFinished();
|
||||||
if(group->allDownloadFinished()) {
|
if(group->allDownloadFinished()) {
|
||||||
group->getProgressInfoFile()->removeFile();
|
group->removeControlFile();
|
||||||
saveSignature(group);
|
saveSignature(group);
|
||||||
} else {
|
} else {
|
||||||
group->getProgressInfoFile()->save();
|
group->saveControlFile();
|
||||||
}
|
}
|
||||||
RequestGroups nextGroups;
|
RequestGroups nextGroups;
|
||||||
group->postDownloadProcessing(nextGroups);
|
group->postDownloadProcessing(nextGroups);
|
||||||
|
@ -316,7 +316,7 @@ public:
|
||||||
nextGroups.begin(), nextGroups.end());
|
nextGroups.begin(), nextGroups.end());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
group->getProgressInfoFile()->save();
|
group->saveControlFile();
|
||||||
}
|
}
|
||||||
} catch(RecoverableException& ex) {
|
} catch(RecoverableException& ex) {
|
||||||
_logger->error(EX_EXCEPTION_CAUGHT, ex);
|
_logger->error(EX_EXCEPTION_CAUGHT, ex);
|
||||||
|
@ -500,10 +500,10 @@ void RequestGroupMan::save()
|
||||||
for(RequestGroups::iterator itr = _requestGroups.begin();
|
for(RequestGroups::iterator itr = _requestGroups.begin();
|
||||||
itr != _requestGroups.end(); ++itr) {
|
itr != _requestGroups.end(); ++itr) {
|
||||||
if((*itr)->allDownloadFinished()) {
|
if((*itr)->allDownloadFinished()) {
|
||||||
(*itr)->getProgressInfoFile()->removeFile();
|
(*itr)->removeControlFile();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
(*itr)->getProgressInfoFile()->save();
|
(*itr)->saveControlFile();
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
_logger->error(EX_EXCEPTION_CAUGHT, e);
|
_logger->error(EX_EXCEPTION_CAUGHT, e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue