summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-04-16 00:01:57 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-04-16 00:01:57 +0900
commit79298daf5feff76e2f7739e37c9f853d722afc94 (patch)
tree038e75419708282bbe0f968ec5e34ab6af05b478
parent7105ce31f232b895e859a612ab8f1a551b12ea2a (diff)
parent7f2f83c6fb30492196573dc75d0170fd1f6a1d84 (diff)
Merge branch 'kkartaltepe-RpcTellStatus-Hashing'
-rw-r--r--doc/manual-src/en/aria2c.rst9
-rw-r--r--src/RpcMethodImpl.cc20
-rw-r--r--src/RpcMethodImpl.h1
-rw-r--r--src/SequentialPicker.h15
4 files changed, 45 insertions, 0 deletions
diff --git a/doc/manual-src/en/aria2c.rst b/doc/manual-src/en/aria2c.rst
index b7808dd3..ae3658c6 100644
--- a/doc/manual-src/en/aria2c.rst
+++ b/doc/manual-src/en/aria2c.rst
@@ -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::
diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc
index 3b2c7d39..d808d83c 100644
--- a/src/RpcMethodImpl.cc
+++ b/src/RpcMethodImpl.cc
@@ -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
diff --git a/src/RpcMethodImpl.h b/src/RpcMethodImpl.h
index a3e4ffeb..de6d7685 100644
--- a/src/RpcMethodImpl.h
+++ b/src/RpcMethodImpl.h
@@ -54,6 +54,7 @@ namespace aria2 {
struct DownloadResult;
class RequestGroup;
+class CheckIntegrityEntry;
namespace rpc {
diff --git a/src/SequentialPicker.h b/src/SequentialPicker.h
index e8485041..eb4489b0 100644
--- a/src/SequentialPicker.h
+++ b/src/SequentialPicker.h
@@ -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