Преглед на файлове

2007-11-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Changed CheckIntegrityEntry interface so that it can define
the action when all the chunk checksums are valid.
* src/CheckIntegrityEntry.h
* src/StreamCheckIntegrityEntry.{h, cc}
* src/BtCheckIntegrityEntry.{h, cc}: Currently,when all the
checksums
are valid, then aira2 goes to seeding mode. Sometimes it is
better
to exit rather than doing seeding. So, it would be good to
toggle this
behavior.
* src/CheckIntegrityCommand.cc
* src/AbstractCommand.cc
* src/RequestGroup.cc

Tatsuhiro Tsujikawa преди 18 години
родител
ревизия
76b9093d09

+ 14 - 0
ChangeLog

@@ -1,3 +1,17 @@
+2007-11-08  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+	
+	Changed CheckIntegrityEntry interface so that it can define
+	the action when all the chunk checksums are valid.
+	* src/CheckIntegrityEntry.h
+	* src/StreamCheckIntegrityEntry.{h, cc}
+	* src/BtCheckIntegrityEntry.{h, cc}: Currently,when all the checksums
+	are valid, then aira2 goes to seeding mode. Sometimes it is better
+	to exit rather than doing seeding. So, it would be good to toggle this
+	behavior.
+	* src/CheckIntegrityCommand.cc
+	* src/AbstractCommand.cc
+	* src/RequestGroup.cc
+
 2007-11-07  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Reflect the download length of in-flight pieces.

+ 3 - 2
TODO

@@ -47,10 +47,11 @@
 * Limit the number of opening file to,say,100 in MultiDiskAdaptor.
 * Implement the feature to treat http/ftp as auxuality download method for BitTorrent
 * http-seeding(single and multi-file torrent)
+* Use content-type for PostDownloadHandler
 
 -- remaining features to be implemented for 0.12.0 release
 * Reimplement ChecksumCommand(validation using 1 checksum for 1 file)
 * Implement duplicate download checking in Bt
 * improve --metalink-location field
-* Use content-type for PostDownloadHandler
-
+* Do not connect a server when before checking file integrity.
+* If size and filename is provided(for example, metalink), "HEAD" like behavior is unnecessary.

+ 1 - 1
src/AbstractCommand.cc

@@ -425,6 +425,6 @@ void AbstractCommand::prepareForNextAction(Command* nextCommand)
   } else
 #endif // ENABLE_MESSAGE_DIGEST
     {
-      e->addCommand(entry->prepareForNextAction(e));
+      e->addCommand(entry->onDownloadIncomplete(e));
     }
 }

+ 10 - 1
src/BtCheckIntegrityEntry.cc

@@ -47,7 +47,7 @@ BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup):
 
 BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {}
 
-Commands BtCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e)
+Commands BtCheckIntegrityEntry::onDownloadIncomplete(DownloadEngine* e)
 {
   Commands commands;
   FileAllocationEntryHandle entry = new BtFileAllocationEntry(_requestGroup);
@@ -58,3 +58,12 @@ Commands BtCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e)
   }
   return commands;
 }
+
+Commands BtCheckIntegrityEntry::onDownloadFinished(DownloadEngine* e)
+{
+  // TODO Currently,when all the checksums
+  // are valid, then aira2 goes to seeding mode. Sometimes it is better
+  // to exit rather than doing seeding. So, it would be good to toggle this
+  // behavior.
+  return onDownloadIncomplete(e);
+}

+ 3 - 1
src/BtCheckIntegrityEntry.h

@@ -43,7 +43,9 @@ public:
 
   virtual ~BtCheckIntegrityEntry();
 
-  virtual Commands prepareForNextAction(DownloadEngine* e);
+  virtual Commands onDownloadFinished(DownloadEngine* e);
+
+  virtual Commands onDownloadIncomplete(DownloadEngine* e);
 };
 
 typedef SharedHandle<BtCheckIntegrityEntry> BtCheckIntegrityEntryHandle;

+ 2 - 1
src/CheckIntegrityCommand.cc

@@ -65,8 +65,9 @@ bool CheckIntegrityCommand::executeInternal()
     _entry->updatePieceStorage();
     if(_requestGroup->downloadFinished()) {
       logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str());
+      _e->addCommand(_entry->onDownloadFinished(_e));
     } else {
-      _e->addCommand(_entry->prepareForNextAction(_e));
+      _e->addCommand(_entry->onDownloadIncomplete(_e));
     }
     return true;
   } else {

+ 3 - 1
src/CheckIntegrityEntry.h

@@ -66,7 +66,9 @@ public:
 
   void updatePieceStorage();
 
-  virtual Commands prepareForNextAction(DownloadEngine* e) = 0;
+  virtual Commands onDownloadFinished(DownloadEngine* e) = 0;
+
+  virtual Commands onDownloadIncomplete(DownloadEngine* e) = 0;
 };
 
 typedef SharedHandle<CheckIntegrityEntry> CheckIntegrityEntryHandle;

+ 1 - 1
src/RequestGroup.cc

@@ -214,7 +214,7 @@ Commands RequestGroup::createInitialCommand(DownloadEngine* e)
       } else
 #endif // ENABLE_MESSAGE_DIGEST
 	{
-	  commands = entry->prepareForNextAction(e);
+	  commands = entry->onDownloadIncomplete(e);
 	}
       return commands;
     }

+ 6 - 1
src/StreamCheckIntegrityEntry.cc

@@ -51,7 +51,7 @@ StreamCheckIntegrityEntry::StreamCheckIntegrityEntry(const RequestHandle& curren
 
 StreamCheckIntegrityEntry::~StreamCheckIntegrityEntry() {}
 
-Commands StreamCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e)
+Commands StreamCheckIntegrityEntry::onDownloadIncomplete(DownloadEngine* e)
 {
   Commands commands;
   if(_requestGroup->needsFileAllocation()) {
@@ -73,3 +73,8 @@ Commands StreamCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e)
   }
   return commands;
 }
+
+Commands StreamCheckIntegrityEntry::onDownloadFinished(DownloadEngine* e)
+{
+  return Commands();
+}

+ 3 - 1
src/StreamCheckIntegrityEntry.h

@@ -57,7 +57,9 @@ public:
 
   virtual ~StreamCheckIntegrityEntry();
 
-  virtual Commands prepareForNextAction(DownloadEngine* e);
+  virtual Commands onDownloadFinished(DownloadEngine* e);
+
+  virtual Commands onDownloadIncomplete(DownloadEngine* e);
 };
 
 typedef SharedHandle<StreamCheckIntegrityEntry> StreamCheckIntegrityEntryHandle;