From 5cd0108f93d9b91e30b74ec92e66571493a2b997 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 8 Apr 2010 12:54:14 +0000 Subject: [PATCH] 2010-04-08 Tatsuhiro Tsujikawa Added --save-session=FILE option. This option saves error/unfinished downloads to FILE on exit. You can pass this output file to aria2c with -i option on restart. Please note that downloads added by aria2.addTorrent and aria2.addMetalink XML-RPC method are not saved. * src/BtPostDownloadHandler.cc * src/DownloadResult.h * src/Makefile.am * src/MetadataInfo.cc * src/MetadataInfo.h * src/Metalink2RequestGroup.cc * src/MetalinkPostDownloadHandler.cc * src/MultiUrlRequestInfo.cc * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/RequestGroup.h * src/SessionSerializer.cc * src/SessionSerializer.h * src/UTMetadataPostDownloadHandler.cc * src/download_helper.cc * src/download_helper.h * src/prefs.cc * src/prefs.h * src/usage_text.h * test/Makefile.am * test/SessionSerializerTest.cc * test/XmlRpcMethodTest.cc * test/serialize_session.meta4 --- ChangeLog | 31 ++++ doc/aria2c.1 | 15 +- doc/aria2c.1.html | 13 +- doc/aria2c.1.txt | 7 + src/BtPostDownloadHandler.cc | 5 + src/DownloadResult.h | 14 +- src/Makefile.am | 4 +- src/Makefile.in | 29 ++-- src/MetadataInfo.cc | 49 +++++++ src/MetadataInfo.h | 76 ++++++++++ src/Metalink2RequestGroup.cc | 17 ++- src/MetalinkPostDownloadHandler.cc | 6 + src/MultiUrlRequestInfo.cc | 11 ++ src/OptionHandlerFactory.cc | 9 ++ src/RequestGroup.cc | 4 +- src/RequestGroup.h | 13 ++ src/SessionSerializer.cc | 203 +++++++++++++++++++++++++++ src/SessionSerializer.h | 65 +++++++++ src/UTMetadataPostDownloadHandler.cc | 5 +- src/download_helper.cc | 29 ++++ src/download_helper.h | 14 ++ src/prefs.cc | 6 +- src/prefs.h | 6 +- src/usage_text.h | 6 + test/Makefile.am | 3 +- test/Makefile.in | 18 ++- test/SessionSerializerTest.cc | 71 ++++++++++ test/XmlRpcMethodTest.cc | 4 +- test/serialize_session.meta4 | 9 ++ 29 files changed, 707 insertions(+), 35 deletions(-) create mode 100644 src/MetadataInfo.cc create mode 100644 src/MetadataInfo.h create mode 100644 src/SessionSerializer.cc create mode 100644 src/SessionSerializer.h create mode 100644 test/SessionSerializerTest.cc create mode 100644 test/serialize_session.meta4 diff --git a/ChangeLog b/ChangeLog index 6fdcad1b..bc92659a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2010-04-08 Tatsuhiro Tsujikawa + + Added --save-session=FILE option. This option saves + error/unfinished downloads to FILE on exit. You can pass this + output file to aria2c with -i option on restart. Please note that + downloads added by aria2.addTorrent and aria2.addMetalink XML-RPC + method are not saved. + * src/BtPostDownloadHandler.cc + * src/DownloadResult.h + * src/Makefile.am + * src/MetadataInfo.cc + * src/MetadataInfo.h + * src/Metalink2RequestGroup.cc + * src/MetalinkPostDownloadHandler.cc + * src/MultiUrlRequestInfo.cc + * src/OptionHandlerFactory.cc + * src/RequestGroup.cc + * src/RequestGroup.h + * src/SessionSerializer.cc + * src/SessionSerializer.h + * src/UTMetadataPostDownloadHandler.cc + * src/download_helper.cc + * src/download_helper.h + * src/prefs.cc + * src/prefs.h + * src/usage_text.h + * test/Makefile.am + * test/SessionSerializerTest.cc + * test/XmlRpcMethodTest.cc + * test/serialize_session.meta4 + 2010-04-07 Tatsuhiro Tsujikawa Fixed the bug that FTP data connection is not established via diff --git a/doc/aria2c.1 b/doc/aria2c.1 index c56cf6a7..478e928b 100644 --- a/doc/aria2c.1 +++ b/doc/aria2c.1 @@ -2,12 +2,12 @@ .\" Title: aria2c .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.75.2 -.\" Date: 04/03/2010 +.\" Date: 04/08/2010 .\" Manual: Aria2 Manual .\" Source: Aria2 1.9.1a .\" Language: English .\" -.TH "ARIA2C" "1" "04/03/2010" "Aria2 1\&.9\&.1a" "Aria2 Manual" +.TH "ARIA2C" "1" "04/08/2010" "Aria2 1\&.9\&.1a" "Aria2 Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -1354,6 +1354,17 @@ For Metalink downloads, \-C1 is recommended for proxy server which disables resu .sp .5v .RE .PP +\fB\-\-save\-session\fR=FILE +.RS 4 +Save error/unfinished downloads to FILE on exit\&. You can pass this output file to aria2c with +\fB\-i\fR +option on restart\&. Please note that downloads added by +\fBaria2\&.addTorrent\fR +and +\fBaria2\&.addMetalink\fR +XML\-RPC method are not saved\&. +.RE +.PP \fB\-\-stop\fR=SEC .RS 4 Stop application after SEC seconds has passed\&. If diff --git a/doc/aria2c.1.html b/doc/aria2c.1.html index 412e7617..fadabc7b 100644 --- a/doc/aria2c.1.html +++ b/doc/aria2c.1.html @@ -2201,6 +2201,17 @@ connections.
+--save-session=FILE +
+
+

+ Save error/unfinished downloads to FILE on exit. You can pass this + output file to aria2c with -i option on restart. Please note that + downloads added by aria2.addTorrent and aria2.addMetalink + XML-RPC method are not saved. +

+
+
--stop=SEC
@@ -4137,7 +4148,7 @@ files in the program, then also delete it here.


diff --git a/doc/aria2c.1.txt b/doc/aria2c.1.txt index 1dba74dd..7bcbad71 100644 --- a/doc/aria2c.1.txt +++ b/doc/aria2c.1.txt @@ -914,6 +914,13 @@ For Metalink downloads, -C1 is recommended for proxy server which disables resume, in order to avoid establishing unnecessary connections. +*--save-session*=FILE:: + + Save error/unfinished downloads to FILE on exit. You can pass this + output file to aria2c with *-i* option on restart. Please note that + downloads added by *aria2.addTorrent* and *aria2.addMetalink* + XML-RPC method are not saved. + *--stop*=SEC:: Stop application after SEC seconds has passed. If '0' is given, this feature is disabled. diff --git a/src/BtPostDownloadHandler.cc b/src/BtPostDownloadHandler.cc index 0281e9f6..2398d7f7 100644 --- a/src/BtPostDownloadHandler.cc +++ b/src/BtPostDownloadHandler.cc @@ -82,6 +82,11 @@ void BtPostDownloadHandler::getNextRequestGroups std::vector(), content); requestGroup->followedBy(newRgs.begin(), newRgs.end()); + SharedHandle mi = + createMetadataInfoFromFirstFileEntry(requestGroup->getDownloadContext()); + if(!mi.isNull()) { + setMetadataInfo(newRgs.begin(), newRgs.end(), mi); + } groups.insert(groups.end(), newRgs.begin(), newRgs.end()); } diff --git a/src/DownloadResult.h b/src/DownloadResult.h index 7318d946..54c0f924 100644 --- a/src/DownloadResult.h +++ b/src/DownloadResult.h @@ -45,6 +45,8 @@ #include "SharedHandle.h" #include "DownloadResultCode.h" #include "RequestGroup.h" +#include "Option.h" +#include "MetadataInfo.h" namespace aria2 { @@ -74,6 +76,10 @@ public: // RequestGroup.cc::_belongsToGID. gid_t belongsTo; + SharedHandle