diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-03-01 02:26:29 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-03-01 02:26:29 +0000 |
| commit | bc1cf6ed2d4c7ef52263a781359a73edb546970d (patch) | |
| tree | 53e682f047a0465761b415708669b27cc981ce33 /src | |
| parent | d770d1c40af48bb8f288b3ee4c9670289d9c2e45 (diff) | |
* AbstractCommand.cc:
* DownloadCommand.{h, cc}: Aborted downloading commands now
properly
unregister its cuid from SegmentMan.
* DownloadEngine.cc: .aria2 file was written when a downloading
failed with errors.
Diffstat (limited to 'src')
| -rw-r--r-- | src/AbstractCommand.cc | 15 | ||||
| -rw-r--r-- | src/AbstractCommand.h | 2 | ||||
| -rw-r--r-- | src/DownloadCommand.cc | 5 | ||||
| -rw-r--r-- | src/DownloadCommand.h | 1 | ||||
| -rw-r--r-- | src/DownloadEngine.cc | 3 |
5 files changed, 13 insertions, 13 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 6fe1d2ae..7caa1fa7 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -99,11 +99,14 @@ bool AbstractCommand::execute() { return true; } catch(DlRetryEx* err) { e->logger->error(MSG_RESTARTING_DOWNLOAD, err, cuid); - delete(err); - //req->resetUrl(); req->addTryCount(); - if(e->option->getAsInt(PREF_MAX_TRIES) != 0 && - req->getTryCount() >= e->option->getAsInt(PREF_MAX_TRIES)) { + bool isAbort = e->option->getAsInt(PREF_MAX_TRIES) != 0 && + req->getTryCount() >= e->option->getAsInt(PREF_MAX_TRIES); + if(isAbort) { + onAbort(err); + } + delete(err); + if(isAbort) { e->logger->error(MSG_MAX_TRY, cuid, req->getTryCount()); return true; } else { @@ -123,7 +126,9 @@ bool AbstractCommand::prepareForRetry(int wait) { return true; } -void AbstractCommand::onAbort(Exception* e) { +void AbstractCommand::onAbort(Exception* ex) { + e->logger->debug(MSG_UNREGISTER_CUID, cuid); + e->segmentMan->unregisterId(cuid); } void AbstractCommand::setReadCheckSocket(Socket* socket) { diff --git a/src/AbstractCommand.h b/src/AbstractCommand.h index 0a4075e7..e6328a71 100644 --- a/src/AbstractCommand.h +++ b/src/AbstractCommand.h @@ -39,7 +39,7 @@ protected: Socket* socket; virtual bool prepareForRetry(int wait); - virtual void onAbort(Exception* e); + virtual void onAbort(Exception* ex); virtual bool executeInternal(Segment segment) = 0; void setReadCheckSocket(Socket* socket); diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index b771cbe5..5b582c98 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -99,8 +99,3 @@ bool DownloadCommand::prepareForNextSegment() { return true; } } - -void DownloadCommand::onAbort(Exception* ex) { - e->logger->debug(MSG_UNREGISTER_CUID, cuid); - e->segmentMan->unregisterId(cuid); -} diff --git a/src/DownloadCommand.h b/src/DownloadCommand.h index 4e26eb7c..79aaf2e5 100644 --- a/src/DownloadCommand.h +++ b/src/DownloadCommand.h @@ -38,7 +38,6 @@ protected: bool prepareForRetry(int wait); bool prepareForNextSegment(); - void onAbort(Exception* ex); public: DownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* s); virtual ~DownloadCommand(); diff --git a/src/DownloadEngine.cc b/src/DownloadEngine.cc index ff38fa17..965699d0 100644 --- a/src/DownloadEngine.cc +++ b/src/DownloadEngine.cc @@ -78,11 +78,12 @@ void DownloadEngine::run() { } } - segmentMan->removeIfFinished(); diskWriter->closeFile(); if(segmentMan->finished()) { + segmentMan->remove(); cout << "\nThe download was complete. <" << segmentMan->getFilePath() << ">" << endl; } else { + segmentMan->save(); cout << "\nThe download was not complete because of errors. Check the log." << endl; } } |
