mirror of https://github.com/aria2/aria2
2009-05-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Set DownloadResult::IN_PROGRESS for downloads removed by xml-rpc command. * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/XmlRpcMethodImpl.cc * test/RequestGroupTest.ccpull/1/head
parent
933866e315
commit
7e7f809339
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2009-05-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Set DownloadResult::IN_PROGRESS for downloads removed by xml-rpc
|
||||
command.
|
||||
* src/RequestGroup.cc
|
||||
* src/RequestGroup.h
|
||||
* src/RequestGroupMan.cc
|
||||
* src/XmlRpcMethodImpl.cc
|
||||
* test/RequestGroupTest.cc
|
||||
|
||||
2009-05-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added more options that can be specified in -i list and xml-rpc
|
||||
|
|
|
@ -123,6 +123,7 @@ RequestGroup::RequestGroup(const SharedHandle<Option>& option,
|
|||
_preLocalFileCheckEnabled(true),
|
||||
_haltRequested(false),
|
||||
_forceHaltRequested(false),
|
||||
_haltReason(RequestGroup::NONE),
|
||||
_singleHostMultiConnectionEnabled(true),
|
||||
_uriSelector(new InOrderURISelector()),
|
||||
_lastModifiedTime(Time::null()),
|
||||
|
@ -179,7 +180,11 @@ DownloadResult::RESULT RequestGroup::downloadResult() const
|
|||
return DownloadResult::FINISHED;
|
||||
else {
|
||||
if (_uriResults.empty()) {
|
||||
return DownloadResult::UNKNOWN_ERROR;
|
||||
if(_haltReason == RequestGroup::USER_REQUEST) {
|
||||
return DownloadResult::IN_PROGRESS;
|
||||
} else {
|
||||
return DownloadResult::UNKNOWN_ERROR;
|
||||
}
|
||||
} else {
|
||||
return _uriResults.back().getResult();
|
||||
}
|
||||
|
@ -793,9 +798,12 @@ TransferStat RequestGroup::calculateStat()
|
|||
return stat;
|
||||
}
|
||||
|
||||
void RequestGroup::setHaltRequested(bool f)
|
||||
void RequestGroup::setHaltRequested(bool f, HaltReason haltReason)
|
||||
{
|
||||
_haltRequested = f;
|
||||
if(_haltRequested) {
|
||||
_haltReason = haltReason;
|
||||
}
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
if(!_btRuntime.isNull()) {
|
||||
_btRuntime->setHalt(f);
|
||||
|
@ -803,9 +811,9 @@ void RequestGroup::setHaltRequested(bool f)
|
|||
#endif // ENABLE_BITTORRENT
|
||||
}
|
||||
|
||||
void RequestGroup::setForceHaltRequested(bool f)
|
||||
void RequestGroup::setForceHaltRequested(bool f, HaltReason haltReason)
|
||||
{
|
||||
setHaltRequested(f);
|
||||
setHaltRequested(f, haltReason);
|
||||
_forceHaltRequested = f;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,12 @@ class PeerStorage;
|
|||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
class RequestGroup {
|
||||
public:
|
||||
enum HaltReason {
|
||||
NONE,
|
||||
SHUTDOWN_SIGNAL,
|
||||
USER_REQUEST
|
||||
};
|
||||
private:
|
||||
static int32_t _gidCounter;
|
||||
|
||||
|
@ -116,6 +122,8 @@ private:
|
|||
|
||||
bool _forceHaltRequested;
|
||||
|
||||
HaltReason _haltReason;
|
||||
|
||||
// URIResult is stored in the ascending order of the time when its result is
|
||||
// available.
|
||||
std::deque<URIResult> _uriResults;
|
||||
|
@ -320,9 +328,9 @@ public:
|
|||
return _preLocalFileCheckEnabled;
|
||||
}
|
||||
|
||||
void setHaltRequested(bool f);
|
||||
void setHaltRequested(bool f, HaltReason = SHUTDOWN_SIGNAL);
|
||||
|
||||
void setForceHaltRequested(bool f);
|
||||
void setForceHaltRequested(bool f, HaltReason = SHUTDOWN_SIGNAL);
|
||||
|
||||
bool isHaltRequested() const
|
||||
{
|
||||
|
|
|
@ -456,6 +456,9 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|||
if((*itr)->result == DownloadResult::FINISHED) {
|
||||
status = MARK_OK;
|
||||
++ok;
|
||||
} else if((*itr)->result == DownloadResult::IN_PROGRESS) {
|
||||
status = MARK_INPR;
|
||||
++inpr;
|
||||
} else {
|
||||
status = MARK_ERR;
|
||||
++err;
|
||||
|
|
|
@ -150,7 +150,7 @@ BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
|||
(StringFormat("Active Download not found for GID#%d", gid).str());
|
||||
}
|
||||
|
||||
group->setHaltRequested(true);
|
||||
group->setHaltRequested(true, RequestGroup::USER_REQUEST);
|
||||
|
||||
BDE resParams = BDE::list();
|
||||
resParams << BDE("OK");
|
||||
|
|
|
@ -121,6 +121,12 @@ void RequestGroupTest::testCreateDownloadResult()
|
|||
// result is UNKNOWN_ERROR if download has not completed and no specific
|
||||
// error has been reported
|
||||
CPPUNIT_ASSERT_EQUAL(DownloadResult::UNKNOWN_ERROR, result->result);
|
||||
|
||||
// if haltReason is set to RequestGroup::USER_REQUEST, download
|
||||
// result becomes IN_PROGRESS
|
||||
group.setHaltRequested(true, RequestGroup::USER_REQUEST);
|
||||
result = group.createDownloadResult();
|
||||
CPPUNIT_ASSERT_EQUAL(DownloadResult::IN_PROGRESS, result->result);
|
||||
}
|
||||
{
|
||||
group.addURIResult("http://first/file", DownloadResult::TIME_OUT);
|
||||
|
|
Loading…
Reference in New Issue