From bb3a55d080f7da2dbcd2813c582cfd9e608ec3b3 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 8 Mar 2009 12:47:33 +0000 Subject: [PATCH] 2009-03-08 Tatsuhiro Tsujikawa Throw exception if same infohash torrent is now downloading. * src/RequestGroup.cc --- ChangeLog | 5 +++++ src/RequestGroup.cc | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3d7cb8cc..a79c6bd89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-03-08 Tatsuhiro Tsujikawa + + Throw exception if same infohash torrent is now downloading. + * src/RequestGroup.cc + 2009-03-08 Tatsuhiro Tsujikawa Added --dry-run option. In this mode, aria2 just checks whether diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index adc50835a..d12d1b3f8 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -209,6 +209,12 @@ void RequestGroup::createInitialCommand(std::deque& commands, throw DownloadFailureException ("Cancel BitTorrent download in dry-run context."); } + SharedHandle 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& commands, _pieceStorage, _option)); - SharedHandle btRegistry = e->getBtRegistry(); - btRegistry->registerBtContext(btContext->getInfoHashAsString(), btContext); btRegistry->registerPieceStorage(btContext->getInfoHashAsString(),