Merge branch 'kkartaltepe-RpcTellStatus-Hashing'

pull/629/head
Tatsuhiro Tsujikawa 2016-04-16 00:01:57 +09:00
commit 79298daf5f
4 changed files with 45 additions and 0 deletions

View File

@ -2614,6 +2614,15 @@ For information on the *secret* parameter, see :ref:`rpc_auth`.
``name``
name in info dictionary. ``name.utf-8`` is used if available.
``verifiedLength``
The number of verified number of bytes while the files are being
hash checked. This key exists only when this download is being
hash checked.
``verifyIntegrityPending``
``true`` if this download is waiting for the hash check in a
queue. This key exists only when this download is in the queue.
**JSON-RPC Example**
The following example gets information about a download with GID#2089b05ecca3d829::

View File

@ -77,6 +77,7 @@
#include "BtRuntime.h"
#include "BtAnnounce.h"
#endif // ENABLE_BITTORRENT
#include "CheckIntegrityEntry.h"
namespace aria2 {
@ -144,6 +145,8 @@ 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";
const char KEY_VERIFIED_LENGTH[] = "verifiedLength";
const char KEY_VERIFY_PENDING[] = "verifyIntegrityPending";
} // namespace
namespace {
@ -793,6 +796,23 @@ void gatherProgress(Dict* entryDict, const std::shared_ptr<RequestGroup>& group,
e->getBtRegistry()->get(group->getGID()), keys);
}
#endif // ENABLE_BITTORRENT
if (e->getCheckIntegrityMan()) {
if (e->getCheckIntegrityMan()->isPicked(
[&group](const CheckIntegrityEntry& ent) {
return ent.getRequestGroup() == group.get();
})) {
entryDict->put(
KEY_VERIFIED_LENGTH,
util::itos(
e->getCheckIntegrityMan()->getPickedEntry()->getCurrentLength()));
}
if (e->getCheckIntegrityMan()->isQueued(
[&group](const CheckIntegrityEntry& ent) {
return ent.getRequestGroup() == group.get();
})) {
entryDict->put(KEY_VERIFY_PENDING, VLB_TRUE);
}
}
}
} // namespace

View File

@ -54,6 +54,7 @@ namespace aria2 {
struct DownloadResult;
class RequestGroup;
class CheckIntegrityEntry;
namespace rpc {

View File

@ -72,6 +72,21 @@ public:
}
size_t countEntryInQueue() const { return entries_.size(); }
bool isPicked(const std::function<bool(const T&)>& pred) const
{
return pickedEntry_ && pred(*pickedEntry_);
}
bool isQueued(const std::function<bool(const T&)>& pred) const
{
for (auto& e : entries_) {
if (pred(*e)) {
return true;
}
}
return false;
}
};
} // namespace aria2