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())
|
||||
return error_code::FINISHED;
|
||||
else {
|
||||
if(lastErrorCode_ == error_code::UNDEFINED) {
|
||||
if(haltReason_ == RequestGroup::USER_REQUEST ||
|
||||
haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
||||
if(haltReason_ == RequestGroup::USER_REQUEST) {
|
||||
return error_code::REMOVED;
|
||||
} else if(lastErrorCode_ == error_code::UNDEFINED) {
|
||||
if(haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
||||
return error_code::IN_PROGRESS;
|
||||
} else {
|
||||
return error_code::UNKNOWN_ERROR;
|
||||
|
|
|
@ -270,6 +270,7 @@ void executeStopHook
|
|||
!option->blank(PREF_ON_DOWNLOAD_COMPLETE)) {
|
||||
util::executeHookByOptName(group, option, PREF_ON_DOWNLOAD_COMPLETE);
|
||||
} else if(result != error_code::IN_PROGRESS &&
|
||||
result != error_code::REMOVED &&
|
||||
!option->blank(PREF_ON_DOWNLOAD_ERROR)) {
|
||||
util::executeHookByOptName(group, option, PREF_ON_DOWNLOAD_ERROR);
|
||||
} else if(!option->blank(PREF_ON_DOWNLOAD_STOP)) {
|
||||
|
@ -571,6 +572,7 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
|
|||
size_t finished = 0;
|
||||
size_t error = removedErrorResult_;
|
||||
size_t inprogress = 0;
|
||||
size_t removed = 0;
|
||||
error_code::Value lastError = removedLastErrorResult_;
|
||||
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
||||
downloadResults_.begin(), eoi = downloadResults_.end();
|
||||
|
@ -580,12 +582,17 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
|
|||
}
|
||||
if((*itr)->result == error_code::FINISHED) {
|
||||
++finished;
|
||||
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||
++inprogress;
|
||||
} else if((*itr)->result == error_code::REMOVED) {
|
||||
++removed;
|
||||
} else {
|
||||
++error;
|
||||
lastError = (*itr)->result;
|
||||
}
|
||||
}
|
||||
return DownloadStat(finished, error, inprogress, reservedGroups_.size(),
|
||||
return DownloadStat(finished, error, inprogress, removed,
|
||||
reservedGroups_.size(),
|
||||
lastError);
|
||||
}
|
||||
|
||||
|
@ -594,6 +601,7 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|||
static const std::string MARK_OK("OK");
|
||||
static const std::string MARK_ERR("ERR");
|
||||
static const std::string MARK_INPR("INPR");
|
||||
static const std::string MARK_RM("RM");
|
||||
|
||||
// Download Results:
|
||||
// idx|stat|path/length
|
||||
|
@ -611,7 +619,7 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|||
int ok = 0;
|
||||
int err = 0;
|
||||
int inpr = 0;
|
||||
|
||||
int rm = 0;
|
||||
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
||||
downloadResults_.begin(), eoi = downloadResults_.end();
|
||||
itr != eoi; ++itr) {
|
||||
|
@ -625,13 +633,16 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|||
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||
status = MARK_INPR;
|
||||
++inpr;
|
||||
} else if((*itr)->result == error_code::REMOVED) {
|
||||
status = MARK_RM;
|
||||
++rm;
|
||||
} else {
|
||||
status = MARK_ERR;
|
||||
++err;
|
||||
}
|
||||
o << formatDownloadResult(status, *itr) << "\n";
|
||||
}
|
||||
if(ok > 0 || err > 0 || inpr > 0) {
|
||||
if(ok > 0 || err > 0 || inpr > 0 || rm > 0) {
|
||||
o << "\n"
|
||||
<< _("Status Legend:") << "\n";
|
||||
|
||||
|
@ -644,6 +655,9 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|||
if(inpr > 0) {
|
||||
o << "(INPR):download in-progress.";
|
||||
}
|
||||
if(rm > 0) {
|
||||
o << "(RM):download removed.";
|
||||
}
|
||||
o << "\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,18 +171,21 @@ public:
|
|||
size_t completed_;
|
||||
size_t error_;
|
||||
size_t inProgress_;
|
||||
size_t removed_;
|
||||
size_t waiting_;
|
||||
error_code::Value lastErrorResult_;
|
||||
public:
|
||||
DownloadStat(size_t completed,
|
||||
size_t error,
|
||||
size_t inProgress,
|
||||
size_t removed,
|
||||
size_t waiting,
|
||||
error_code::Value lastErrorResult =
|
||||
error_code::FINISHED):
|
||||
completed_(completed),
|
||||
error_(error),
|
||||
inProgress_(inProgress),
|
||||
removed_(removed),
|
||||
waiting_(waiting),
|
||||
lastErrorResult_(lastErrorResult) {}
|
||||
|
||||
|
|
|
@ -800,7 +800,7 @@ void gatherStoppedDownload
|
|||
entryDict->put(KEY_ERROR_CODE, util::itos(static_cast<int>(ds->result)));
|
||||
}
|
||||
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);
|
||||
} else if(ds->result == error_code::FINISHED) {
|
||||
entryDict->put(KEY_STATUS, VLB_COMPLETE);
|
||||
|
|
|
@ -171,7 +171,8 @@ void SessionSerializer::save(std::ostream& out) const
|
|||
rgman_->getDownloadResults();
|
||||
for(std::deque<SharedHandle<DownloadResult> >::const_iterator 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;
|
||||
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||
if(saveInProgress_) {
|
||||
|
|
|
@ -73,7 +73,8 @@ enum Value {
|
|||
MAGNET_PARSE_ERROR = 27,
|
||||
OPTION_ERROR = 28,
|
||||
HTTP_SERVICE_UNAVAILABLE = 29,
|
||||
JSON_PARSE_ERROR = 30
|
||||
JSON_PARSE_ERROR = 30,
|
||||
REMOVED = 31
|
||||
};
|
||||
|
||||
} // namespace error_code
|
||||
|
|
|
@ -67,9 +67,14 @@ void RequestGroupTest::testCreateDownloadResult()
|
|||
CPPUNIT_ASSERT_EQUAL(error_code::UNKNOWN_ERROR, result->result);
|
||||
|
||||
// if haltReason is set to RequestGroup::USER_REQUEST, download
|
||||
// result becomes IN_PROGRESS
|
||||
// result will become REMOVED.
|
||||
group.setHaltRequested(true, RequestGroup::USER_REQUEST);
|
||||
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);
|
||||
}
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "prefs.h"
|
||||
#include "Option.h"
|
||||
#include "a2functional.h"
|
||||
#include "FileEntry.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -26,6 +27,25 @@ public:
|
|||
|
||||
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()
|
||||
{
|
||||
#if defined(ENABLE_BITTORRENT) && defined(ENABLE_METALINK)
|
||||
|
@ -41,13 +61,21 @@ void SessionSerializerTest::testSave()
|
|||
option->put(PREF_DIR, "/tmp");
|
||||
createRequestGroupForUri(result, option, uris);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)5, result.size());
|
||||
option->put(PREF_MAX_DOWNLOAD_RESULT, "10");
|
||||
SharedHandle<RequestGroupMan> rgman
|
||||
(new RequestGroupMan(result, 1, option.get()));
|
||||
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;
|
||||
s.save(ss);
|
||||
std::string 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);
|
||||
std::getline(ss, line);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(" dir=/tmp"), line);
|
||||
|
|
Loading…
Reference in New Issue