2007-10-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Use RequestGroup::allDownloadFinished() to decide whether the 
control
	file should be removed or saved.
	* src/RequestGroup.{h, cc} (allDownloadFinished): New function.
	* src/RequestGroupMan.cc (removeStoppedGroup) (save)
pull/1/head
Tatsuhiro Tsujikawa 2007-10-29 14:06:59 +00:00
parent 8b27671e58
commit f3f8cc593c
5 changed files with 27 additions and 5 deletions

View File

@ -1,3 +1,10 @@
2007-10-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use RequestGroup::allDownloadFinished() to decide whether the control
file should be removed or saved.
* src/RequestGroup.{h, cc} (allDownloadFinished): New function.
* src/RequestGroupMan.cc (removeStoppedGroup) (save)
2007-10-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use File::renameTo()

4
TODO
View File

@ -57,6 +57,4 @@
* Use content-type for PostDownloadHandler
* Torrent information
* Fix SleepCommand to catch halt signal
* set prealloc default for --file-allocaiton option.
* Add allDownloadFinished to RequestGroup to erase .aria2 file after download finished. RequestGroup::downloadFinished() can not be used here because it doesn't work properly when selective download
* Call Segment::updateSubPiece to reflect partial download information to subpiece.

View File

@ -116,6 +116,15 @@ bool RequestGroup::downloadFinished() const
}
}
bool RequestGroup::allDownloadFinished() const
{
if(_pieceStorage.isNull()) {
return false;
} else {
return _pieceStorage->allDownloadFinished();
}
}
void RequestGroup::closeFile()
{
if(!_pieceStorage.isNull()) {

View File

@ -149,6 +149,8 @@ public:
bool downloadFinished() const;
bool allDownloadFinished() const;
void closeFile();
string getFilePath() const;

View File

@ -105,7 +105,11 @@ void RequestGroupMan::removeStoppedGroup()
if((*itr)->downloadFinished()) {
_logger->notice(MSG_FILE_DOWNLOAD_COMPLETED,
(*itr)->getFilePath().c_str());
(*itr)->getProgressInfoFile()->removeFile();
if((*itr)->allDownloadFinished()) {
(*itr)->getProgressInfoFile()->removeFile();
} else {
(*itr)->getProgressInfoFile()->save();
}
RequestGroups nextGroups = (*itr)->postDownloadProcessing();
if(nextGroups.size() > 0) {
_logger->debug("Adding %d RequestGroups as a result of PostDownloadHandler.", (int32_t)nextGroups.size());
@ -185,7 +189,9 @@ void RequestGroupMan::save()
{
for(RequestGroups::iterator itr = _requestGroups.begin();
itr != _requestGroups.end(); ++itr) {
if(!(*itr)->downloadFinished()) {
if((*itr)->allDownloadFinished()) {
(*itr)->getProgressInfoFile()->removeFile();
} else {
try {
(*itr)->getProgressInfoFile()->save();
} catch(DlAbortEx* e) {