2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

When there is not enough space in disk when writing a chunk of 
data,
	aria2 now prints the message to the console to warn user and 
aborts
	its download. Not all downloads are canceled because some 
downloads
	may use another disk or partition. BUG#1640332
	* src/AbstractDiskWriter.cc
	* src/PeerAbstractCommand.cc
	* src/PeerAbstractCommand.h: Added onFailure() function for 
override.
	* src/PeerInteractionCommand.cc: In onFailure(), call 
RequestGroup::
	setHaltRequested(true) to cancel download.
	* src/PeerInteractionCommand.h
pull/1/head
Tatsuhiro Tsujikawa 2008-06-16 15:11:41 +00:00
parent 953d1683a3
commit 1c2dd30bf7
6 changed files with 36 additions and 0 deletions

View File

@ -1,3 +1,16 @@
2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
When there is not enough space in disk when writing a chunk of data,
aria2 now prints the message to the console to warn user and aborts
its download. Not all downloads are canceled because some downloads
may use another disk or partition. BUG#1640332
* src/AbstractDiskWriter.cc
* src/PeerAbstractCommand.cc
* src/PeerAbstractCommand.h: Added onFailure() function for override.
* src/PeerInteractionCommand.cc: In onFailure(), call RequestGroup::
setHaltRequested(true) to cancel download.
* src/PeerInteractionCommand.h
2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Applied Ross's aria2-0.13.2+1-mingw-5.patch, which changes the type of Applied Ross's aria2-0.13.2+1-mingw-5.patch, which changes the type of

View File

@ -41,6 +41,7 @@
#include "DlAbortEx.h" #include "DlAbortEx.h"
#include "a2io.h" #include "a2io.h"
#include "StringFormat.h" #include "StringFormat.h"
#include "DownloadFailureException.h"
#include <cerrno> #include <cerrno>
#include <cstring> #include <cstring>
#include <cassert> #include <cassert>
@ -133,6 +134,12 @@ void AbstractDiskWriter::writeData(const unsigned char* data, size_t len, off_t
{ {
seek(offset); seek(offset);
if(writeDataInternal(data, len) < 0) { if(writeDataInternal(data, len) < 0) {
// If errno is ENOSPC(not enough space in device), throw
// DownloadFailureException and abort download instantly.
if(errno == ENOSPC) {
throw DownloadFailureException
(StringFormat(EX_FILE_WRITE, filename.c_str(), strerror(errno)).str());
}
throw DlAbortEx(StringFormat(EX_FILE_WRITE, filename.c_str(), strerror(errno)).str()); throw DlAbortEx(StringFormat(EX_FILE_WRITE, filename.c_str(), strerror(errno)).str());
} }
} }

View File

@ -41,6 +41,7 @@
#include "Logger.h" #include "Logger.h"
#include "message.h" #include "message.h"
#include "prefs.h" #include "prefs.h"
#include "DownloadFailureException.h"
namespace aria2 { namespace aria2 {
@ -83,6 +84,11 @@ bool PeerAbstractCommand::execute() {
throw DlAbortEx(EX_TIME_OUT); throw DlAbortEx(EX_TIME_OUT);
} }
return executeInternal(); return executeInternal();
} catch(DownloadFailureException& err) {
logger->error(EX_DOWNLOAD_ABORTED, err);
onAbort();
onFailure();
return true;
} catch(RecoverableException& err) { } catch(RecoverableException& err) {
logger->debug(MSG_TORRENT_DOWNLOAD_ABORTED, err, cuid); logger->debug(MSG_TORRENT_DOWNLOAD_ABORTED, err, cuid);
logger->debug(MSG_PEER_BANNED, logger->debug(MSG_PEER_BANNED,

View File

@ -58,6 +58,9 @@ protected:
void setTimeout(time_t timeout) { this->timeout = timeout; } void setTimeout(time_t timeout) { this->timeout = timeout; }
virtual bool prepareForNextPeer(time_t wait); virtual bool prepareForNextPeer(time_t wait);
virtual void onAbort() {}; virtual void onAbort() {};
// This function is called when DownloadFailureException is caught right after
// the invocation of onAbort().
virtual void onFailure() {};
virtual bool exitBeforeExecute() = 0; virtual bool exitBeforeExecute() = 0;
virtual bool executeInternal() = 0; virtual bool executeInternal() = 0;
void setReadCheckSocket(const SharedHandle<SocketCore>& socket); void setReadCheckSocket(const SharedHandle<SocketCore>& socket);

View File

@ -63,6 +63,7 @@
#include "DHTSetup.h" #include "DHTSetup.h"
#include "DHTRegistry.h" #include "DHTRegistry.h"
#include "PieceStorage.h" #include "PieceStorage.h"
#include "RequestGroup.h"
#include <algorithm> #include <algorithm>
namespace aria2 { namespace aria2 {
@ -276,6 +277,11 @@ void PeerInteractionCommand::onAbort() {
peerStorage->returnPeer(peer); peerStorage->returnPeer(peer);
} }
void PeerInteractionCommand::onFailure()
{
_requestGroup->setHaltRequested(true);
}
bool PeerInteractionCommand::exitBeforeExecute() bool PeerInteractionCommand::exitBeforeExecute()
{ {
return btRuntime->isHalt(); return btRuntime->isHalt();

View File

@ -62,6 +62,7 @@ protected:
virtual bool executeInternal(); virtual bool executeInternal();
virtual bool prepareForNextPeer(time_t wait); virtual bool prepareForNextPeer(time_t wait);
virtual void onAbort(); virtual void onAbort();
virtual void onFailure();
virtual bool exitBeforeExecute(); virtual bool exitBeforeExecute();
public: public:
PeerInteractionCommand(int32_t cuid, PeerInteractionCommand(int32_t cuid,