소스 검색

2009-03-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Throw exception if same infohash torrent is now downloading.
	* src/RequestGroup.cc
Tatsuhiro Tsujikawa 16 년 전
부모
커밋
bb3a55d080
2개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 0
      ChangeLog
  2. 6 2
      src/RequestGroup.cc

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2009-03-08  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Throw exception if same infohash torrent is now downloading.
+	* src/RequestGroup.cc
+	
 2009-03-08  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Added --dry-run option.  In this mode, aria2 just checks whether

+ 6 - 2
src/RequestGroup.cc

@@ -209,6 +209,12 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
 	throw DownloadFailureException
 	  ("Cancel BitTorrent download in dry-run context.");
       }
+      SharedHandle<BtRegistry> btRegistry = e->getBtRegistry();
+      if(!btRegistry->getBtContext(btContext->getInfoHashAsString()).isNull()) {
+	throw DownloadFailureException
+	  (StringFormat("InfoHash %s is already registered.",
+			btContext->getInfoHashAsString().c_str()).str());
+      }
 
       if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
 	throw DownloadFailureException
@@ -231,8 +237,6 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
 						       _pieceStorage,
 						       _option));
       
-      SharedHandle<BtRegistry> btRegistry = e->getBtRegistry();
-
       btRegistry->registerBtContext(btContext->getInfoHashAsString(),
 				    btContext);
       btRegistry->registerPieceStorage(btContext->getInfoHashAsString(),