فهرست منبع

Merge branch 'kkartaltepe-RpcTellStatus-Hashing'

Tatsuhiro Tsujikawa 9 سال پیش
والد
کامیت
79298daf5f
4فایلهای تغییر یافته به همراه45 افزوده شده و 0 حذف شده
  1. 9 0
      doc/manual-src/en/aria2c.rst
  2. 20 0
      src/RpcMethodImpl.cc
  3. 1 0
      src/RpcMethodImpl.h
  4. 15 0
      src/SequentialPicker.h

+ 9 - 0
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::

+ 20 - 0
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
 

+ 1 - 0
src/RpcMethodImpl.h

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

+ 15 - 0
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