Selaa lähdekoodia

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)
Tatsuhiro Tsujikawa 18 vuotta sitten
vanhempi
commit
f3f8cc593c
5 muutettua tiedostoa jossa 27 lisäystä ja 5 poistoa
  1. 7 0
      ChangeLog
  2. 1 3
      TODO
  3. 9 0
      src/RequestGroup.cc
  4. 2 0
      src/RequestGroup.h
  5. 8 2
      src/RequestGroupMan.cc

+ 7 - 0
ChangeLog

@@ -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()

+ 1 - 3
TODO

@@ -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.
+

+ 9 - 0
src/RequestGroup.cc

@@ -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()) {

+ 2 - 0
src/RequestGroup.h

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

+ 8 - 2
src/RequestGroupMan.cc

@@ -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) {