mirror of https://github.com/aria2/aria2
Don't save removed download in --save-session text file.
Now stat column of removed downloads in Download Results is 'RM' instead of INPR.pull/1/head
parent
058fdbc42b
commit
4784114281
|
@ -197,9 +197,10 @@ error_code::Value RequestGroup::downloadResult() const
|
||||||
if(downloadFinished() && !downloadContext_->isChecksumVerificationNeeded())
|
if(downloadFinished() && !downloadContext_->isChecksumVerificationNeeded())
|
||||||
return error_code::FINISHED;
|
return error_code::FINISHED;
|
||||||
else {
|
else {
|
||||||
if(lastErrorCode_ == error_code::UNDEFINED) {
|
if(haltReason_ == RequestGroup::USER_REQUEST) {
|
||||||
if(haltReason_ == RequestGroup::USER_REQUEST ||
|
return error_code::REMOVED;
|
||||||
haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
} else if(lastErrorCode_ == error_code::UNDEFINED) {
|
||||||
|
if(haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
||||||
return error_code::IN_PROGRESS;
|
return error_code::IN_PROGRESS;
|
||||||
} else {
|
} else {
|
||||||
return error_code::UNKNOWN_ERROR;
|
return error_code::UNKNOWN_ERROR;
|
||||||
|
|
|
@ -270,6 +270,7 @@ void executeStopHook
|
||||||
!option->blank(PREF_ON_DOWNLOAD_COMPLETE)) {
|
!option->blank(PREF_ON_DOWNLOAD_COMPLETE)) {
|
||||||
util::executeHookByOptName(group, option, PREF_ON_DOWNLOAD_COMPLETE);
|
util::executeHookByOptName(group, option, PREF_ON_DOWNLOAD_COMPLETE);
|
||||||
} else if(result != error_code::IN_PROGRESS &&
|
} else if(result != error_code::IN_PROGRESS &&
|
||||||
|
result != error_code::REMOVED &&
|
||||||
!option->blank(PREF_ON_DOWNLOAD_ERROR)) {
|
!option->blank(PREF_ON_DOWNLOAD_ERROR)) {
|
||||||
util::executeHookByOptName(group, option, PREF_ON_DOWNLOAD_ERROR);
|
util::executeHookByOptName(group, option, PREF_ON_DOWNLOAD_ERROR);
|
||||||
} else if(!option->blank(PREF_ON_DOWNLOAD_STOP)) {
|
} else if(!option->blank(PREF_ON_DOWNLOAD_STOP)) {
|
||||||
|
@ -571,6 +572,7 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
|
||||||
size_t finished = 0;
|
size_t finished = 0;
|
||||||
size_t error = removedErrorResult_;
|
size_t error = removedErrorResult_;
|
||||||
size_t inprogress = 0;
|
size_t inprogress = 0;
|
||||||
|
size_t removed = 0;
|
||||||
error_code::Value lastError = removedLastErrorResult_;
|
error_code::Value lastError = removedLastErrorResult_;
|
||||||
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
||||||
downloadResults_.begin(), eoi = downloadResults_.end();
|
downloadResults_.begin(), eoi = downloadResults_.end();
|
||||||
|
@ -580,12 +582,17 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
|
||||||
}
|
}
|
||||||
if((*itr)->result == error_code::FINISHED) {
|
if((*itr)->result == error_code::FINISHED) {
|
||||||
++finished;
|
++finished;
|
||||||
|
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||||
|
++inprogress;
|
||||||
|
} else if((*itr)->result == error_code::REMOVED) {
|
||||||
|
++removed;
|
||||||
} else {
|
} else {
|
||||||
++error;
|
++error;
|
||||||
lastError = (*itr)->result;
|
lastError = (*itr)->result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DownloadStat(finished, error, inprogress, reservedGroups_.size(),
|
return DownloadStat(finished, error, inprogress, removed,
|
||||||
|
reservedGroups_.size(),
|
||||||
lastError);
|
lastError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,6 +601,7 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
||||||
static const std::string MARK_OK("OK");
|
static const std::string MARK_OK("OK");
|
||||||
static const std::string MARK_ERR("ERR");
|
static const std::string MARK_ERR("ERR");
|
||||||
static const std::string MARK_INPR("INPR");
|
static const std::string MARK_INPR("INPR");
|
||||||
|
static const std::string MARK_RM("RM");
|
||||||
|
|
||||||
// Download Results:
|
// Download Results:
|
||||||
// idx|stat|path/length
|
// idx|stat|path/length
|
||||||
|
@ -611,7 +619,7 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int inpr = 0;
|
int inpr = 0;
|
||||||
|
int rm = 0;
|
||||||
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
||||||
downloadResults_.begin(), eoi = downloadResults_.end();
|
downloadResults_.begin(), eoi = downloadResults_.end();
|
||||||
itr != eoi; ++itr) {
|
itr != eoi; ++itr) {
|
||||||
|
@ -625,13 +633,16 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
||||||
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||||
status = MARK_INPR;
|
status = MARK_INPR;
|
||||||
++inpr;
|
++inpr;
|
||||||
|
} else if((*itr)->result == error_code::REMOVED) {
|
||||||
|
status = MARK_RM;
|
||||||
|
++rm;
|
||||||
} else {
|
} else {
|
||||||
status = MARK_ERR;
|
status = MARK_ERR;
|
||||||
++err;
|
++err;
|
||||||
}
|
}
|
||||||
o << formatDownloadResult(status, *itr) << "\n";
|
o << formatDownloadResult(status, *itr) << "\n";
|
||||||
}
|
}
|
||||||
if(ok > 0 || err > 0 || inpr > 0) {
|
if(ok > 0 || err > 0 || inpr > 0 || rm > 0) {
|
||||||
o << "\n"
|
o << "\n"
|
||||||
<< _("Status Legend:") << "\n";
|
<< _("Status Legend:") << "\n";
|
||||||
|
|
||||||
|
@ -644,6 +655,9 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
||||||
if(inpr > 0) {
|
if(inpr > 0) {
|
||||||
o << "(INPR):download in-progress.";
|
o << "(INPR):download in-progress.";
|
||||||
}
|
}
|
||||||
|
if(rm > 0) {
|
||||||
|
o << "(RM):download removed.";
|
||||||
|
}
|
||||||
o << "\n";
|
o << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,18 +171,21 @@ public:
|
||||||
size_t completed_;
|
size_t completed_;
|
||||||
size_t error_;
|
size_t error_;
|
||||||
size_t inProgress_;
|
size_t inProgress_;
|
||||||
|
size_t removed_;
|
||||||
size_t waiting_;
|
size_t waiting_;
|
||||||
error_code::Value lastErrorResult_;
|
error_code::Value lastErrorResult_;
|
||||||
public:
|
public:
|
||||||
DownloadStat(size_t completed,
|
DownloadStat(size_t completed,
|
||||||
size_t error,
|
size_t error,
|
||||||
size_t inProgress,
|
size_t inProgress,
|
||||||
|
size_t removed,
|
||||||
size_t waiting,
|
size_t waiting,
|
||||||
error_code::Value lastErrorResult =
|
error_code::Value lastErrorResult =
|
||||||
error_code::FINISHED):
|
error_code::FINISHED):
|
||||||
completed_(completed),
|
completed_(completed),
|
||||||
error_(error),
|
error_(error),
|
||||||
inProgress_(inProgress),
|
inProgress_(inProgress),
|
||||||
|
removed_(removed),
|
||||||
waiting_(waiting),
|
waiting_(waiting),
|
||||||
lastErrorResult_(lastErrorResult) {}
|
lastErrorResult_(lastErrorResult) {}
|
||||||
|
|
||||||
|
|
|
@ -800,7 +800,7 @@ void gatherStoppedDownload
|
||||||
entryDict->put(KEY_ERROR_CODE, util::itos(static_cast<int>(ds->result)));
|
entryDict->put(KEY_ERROR_CODE, util::itos(static_cast<int>(ds->result)));
|
||||||
}
|
}
|
||||||
if(requested_key(keys, KEY_STATUS)) {
|
if(requested_key(keys, KEY_STATUS)) {
|
||||||
if(ds->result == error_code::IN_PROGRESS) {
|
if(ds->result == error_code::REMOVED) {
|
||||||
entryDict->put(KEY_STATUS, VLB_REMOVED);
|
entryDict->put(KEY_STATUS, VLB_REMOVED);
|
||||||
} else if(ds->result == error_code::FINISHED) {
|
} else if(ds->result == error_code::FINISHED) {
|
||||||
entryDict->put(KEY_STATUS, VLB_COMPLETE);
|
entryDict->put(KEY_STATUS, VLB_COMPLETE);
|
||||||
|
|
|
@ -171,7 +171,8 @@ void SessionSerializer::save(std::ostream& out) const
|
||||||
rgman_->getDownloadResults();
|
rgman_->getDownloadResults();
|
||||||
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
||||||
results.begin(), eoi = results.end(); itr != eoi; ++itr) {
|
results.begin(), eoi = results.end(); itr != eoi; ++itr) {
|
||||||
if((*itr)->result == error_code::FINISHED) {
|
if((*itr)->result == error_code::FINISHED ||
|
||||||
|
(*itr)->result == error_code::REMOVED) {
|
||||||
continue;
|
continue;
|
||||||
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||||
if(saveInProgress_) {
|
if(saveInProgress_) {
|
||||||
|
|
|
@ -73,7 +73,8 @@ enum Value {
|
||||||
MAGNET_PARSE_ERROR = 27,
|
MAGNET_PARSE_ERROR = 27,
|
||||||
OPTION_ERROR = 28,
|
OPTION_ERROR = 28,
|
||||||
HTTP_SERVICE_UNAVAILABLE = 29,
|
HTTP_SERVICE_UNAVAILABLE = 29,
|
||||||
JSON_PARSE_ERROR = 30
|
JSON_PARSE_ERROR = 30,
|
||||||
|
REMOVED = 31
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace error_code
|
} // namespace error_code
|
||||||
|
|
|
@ -67,9 +67,14 @@ void RequestGroupTest::testCreateDownloadResult()
|
||||||
CPPUNIT_ASSERT_EQUAL(error_code::UNKNOWN_ERROR, result->result);
|
CPPUNIT_ASSERT_EQUAL(error_code::UNKNOWN_ERROR, result->result);
|
||||||
|
|
||||||
// if haltReason is set to RequestGroup::USER_REQUEST, download
|
// if haltReason is set to RequestGroup::USER_REQUEST, download
|
||||||
// result becomes IN_PROGRESS
|
// result will become REMOVED.
|
||||||
group.setHaltRequested(true, RequestGroup::USER_REQUEST);
|
group.setHaltRequested(true, RequestGroup::USER_REQUEST);
|
||||||
result = group.createDownloadResult();
|
result = group.createDownloadResult();
|
||||||
|
CPPUNIT_ASSERT_EQUAL(error_code::REMOVED, result->result);
|
||||||
|
// if haltReason is set to RequestGroup::SHUTDOWN_SIGNAL, download
|
||||||
|
// result will become IN_PROGRESS.
|
||||||
|
group.setHaltRequested(true, RequestGroup::SHUTDOWN_SIGNAL);
|
||||||
|
result = group.createDownloadResult();
|
||||||
CPPUNIT_ASSERT_EQUAL(error_code::IN_PROGRESS, result->result);
|
CPPUNIT_ASSERT_EQUAL(error_code::IN_PROGRESS, result->result);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -26,6 +27,25 @@ public:
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(SessionSerializerTest);
|
CPPUNIT_TEST_SUITE_REGISTRATION(SessionSerializerTest);
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
SharedHandle<DownloadResult> createDownloadResult
|
||||||
|
(error_code::Value result, const std::string& uri)
|
||||||
|
{
|
||||||
|
std::vector<std::string> uris;
|
||||||
|
uris.push_back(uri);
|
||||||
|
SharedHandle<FileEntry> entry(new FileEntry("/tmp/path", 1, 0, uris));
|
||||||
|
std::vector<SharedHandle<FileEntry> > entries;
|
||||||
|
entries.push_back(entry);
|
||||||
|
SharedHandle<DownloadResult> dr(new DownloadResult());
|
||||||
|
dr->fileEntries = entries;
|
||||||
|
dr->result = result;
|
||||||
|
dr->belongsTo = 0;
|
||||||
|
dr->inMemoryDownload = false;
|
||||||
|
dr->option = SharedHandle<Option>(new Option());
|
||||||
|
return dr;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void SessionSerializerTest::testSave()
|
void SessionSerializerTest::testSave()
|
||||||
{
|
{
|
||||||
#if defined(ENABLE_BITTORRENT) && defined(ENABLE_METALINK)
|
#if defined(ENABLE_BITTORRENT) && defined(ENABLE_METALINK)
|
||||||
|
@ -41,13 +61,21 @@ void SessionSerializerTest::testSave()
|
||||||
option->put(PREF_DIR, "/tmp");
|
option->put(PREF_DIR, "/tmp");
|
||||||
createRequestGroupForUri(result, option, uris);
|
createRequestGroupForUri(result, option, uris);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)5, result.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)5, result.size());
|
||||||
|
option->put(PREF_MAX_DOWNLOAD_RESULT, "10");
|
||||||
SharedHandle<RequestGroupMan> rgman
|
SharedHandle<RequestGroupMan> rgman
|
||||||
(new RequestGroupMan(result, 1, option.get()));
|
(new RequestGroupMan(result, 1, option.get()));
|
||||||
SessionSerializer s(rgman);
|
SessionSerializer s(rgman);
|
||||||
|
// REMOVED downloads will not be saved.
|
||||||
|
rgman->addDownloadResult
|
||||||
|
(createDownloadResult(error_code::REMOVED, "http://removed"));
|
||||||
|
rgman->addDownloadResult
|
||||||
|
(createDownloadResult(error_code::TIME_OUT, "http://error"));
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
s.save(ss);
|
s.save(ss);
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(ss, line);
|
std::getline(ss, line);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("http://error\t"), line);
|
||||||
|
std::getline(ss, line);
|
||||||
CPPUNIT_ASSERT_EQUAL(strconcat(uris[0], "\t", uris[1], "\t"), line);
|
CPPUNIT_ASSERT_EQUAL(strconcat(uris[0], "\t", uris[1], "\t"), line);
|
||||||
std::getline(ss, line);
|
std::getline(ss, line);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(" dir=/tmp"), line);
|
CPPUNIT_ASSERT_EQUAL(std::string(" dir=/tmp"), line);
|
||||||
|
|
Loading…
Reference in New Issue