mirror of https://github.com/aria2/aria2
Add numStoppedTotal key to aria2.getGlobalStat() RPC method response
It shows the number of stopped downloads in the current session and not capped by --max-download-result option. On the other hand, the existing numStopped key also shows the number of stopped downloads, but it is capped by --max-download-result option.pull/195/head
parent
154a3e5ffb
commit
1462d6536a
|
@ -3047,7 +3047,12 @@ For *secret* parameter, see :ref:`rpc_auth`.
|
|||
The number of waiting downloads.
|
||||
|
||||
``numStopped``
|
||||
The number of stopped downloads.
|
||||
The number of stopped downloads in the current session. This value
|
||||
is capped by :option:`--max-download-result` option.
|
||||
|
||||
``numStoppedTotal``
|
||||
The number of stopped downloads in the current session and not
|
||||
capped by :option:`--max-download-result` option.
|
||||
|
||||
**JSON-RPC Example**
|
||||
::
|
||||
|
|
|
@ -115,7 +115,8 @@ RequestGroupMan::RequestGroupMan
|
|||
removedLastErrorResult_(error_code::FINISHED),
|
||||
maxDownloadResult_(option->getAsInt(PREF_MAX_DOWNLOAD_RESULT)),
|
||||
wrDiskCache_(nullptr),
|
||||
numOpenFile_(0)
|
||||
numOpenFile_(0),
|
||||
numStoppedTotal_(0)
|
||||
{
|
||||
appendReservedGroup(reservedGroups_,
|
||||
requestGroups.begin(), requestGroups.end());
|
||||
|
@ -832,6 +833,7 @@ bool RequestGroupMan::removeDownloadResult(a2_gid_t gid)
|
|||
|
||||
void RequestGroupMan::addDownloadResult(const std::shared_ptr<DownloadResult>& dr)
|
||||
{
|
||||
++numStoppedTotal_;
|
||||
bool rv = downloadResults_.push_back(dr->gid->getNumericId(), dr);
|
||||
assert(rv);
|
||||
while(downloadResults_.size() > maxDownloadResult_){
|
||||
|
|
|
@ -106,6 +106,10 @@ private:
|
|||
|
||||
size_t numOpenFile_;
|
||||
|
||||
// The number of stopped downloads so far in total, including
|
||||
// evicted DownloadResults.
|
||||
size_t numStoppedTotal_;
|
||||
|
||||
void formatDownloadResultFull
|
||||
(OutputFile& out,
|
||||
const char* status,
|
||||
|
@ -359,6 +363,11 @@ public:
|
|||
void ensureMaxOpenFileLimit(size_t numNewFile);
|
||||
// Reduces the number of open files managed by this object.
|
||||
void reduceNumOfOpenedFile(size_t numCloseFile);
|
||||
|
||||
size_t getNumStoppedTotal() const
|
||||
{
|
||||
return numStoppedTotal_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -142,6 +142,7 @@ const char KEY_SERVERS[] = "servers";
|
|||
const char KEY_NUM_WAITING[] = "numWaiting";
|
||||
const char KEY_NUM_STOPPED[] = "numStopped";
|
||||
const char KEY_NUM_ACTIVE[] = "numActive";
|
||||
const char KEY_NUM_STOPPED_TOTAL[] = "numStoppedTotal";
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
@ -1341,6 +1342,7 @@ std::unique_ptr<ValueBase> GetGlobalStatRpcMethod::process
|
|||
res->put(KEY_UPLOAD_SPEED, util::itos(ts.uploadSpeed));
|
||||
res->put(KEY_NUM_WAITING, util::uitos(rgman->getReservedGroups().size()));
|
||||
res->put(KEY_NUM_STOPPED, util::uitos(rgman->getDownloadResults().size()));
|
||||
res->put(KEY_NUM_STOPPED_TOTAL, util::uitos(rgman->getNumStoppedTotal()));
|
||||
res->put(KEY_NUM_ACTIVE, util::uitos(rgman->getRequestGroups().size()));
|
||||
return std::move(res);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue