From 1aee57f6a2554d98abbfb8709e348c805ff9afad Mon Sep 17 00:00:00 2001
From: Daira Hopwood <daira@jacaranda.org>
Date: Tue, 22 Sep 2015 16:42:02 +0100
Subject: [PATCH] Fix objects_queued counter.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
---
 src/allmydata/frontends/magic_folder.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py
index 96250efd..7b40708f 100644
--- a/src/allmydata/frontends/magic_folder.py
+++ b/src/allmydata/frontends/magic_folder.py
@@ -153,6 +153,7 @@ class QueueMixin(HookMixin):
             return
         try:
             item = self._deque.pop()
+            self._count('objects_queued', -1)
         except IndexError:
             self._log("deque is now empty")
             self._lazy_tail.addCallback(lambda ign: self._when_queue_is_empty())
@@ -340,12 +341,10 @@ class Uploader(QueueMixin):
         d.addCallback(_maybe_upload)
 
         def _succeeded(res):
-            self._count('objects_queued', -1)
             self._count('objects_succeeded')
             return res
         def _failed(f):
             print f
-            self._count('objects_queued', -1)
             self._count('objects_failed')
             self._log("%r while processing %r" % (f, relpath_u))
             return f
@@ -497,6 +496,7 @@ class Downloader(QueueMixin):
         print "deque = %r" % (self._deque,)
         self._deque.extend(result)
         print "deque after = %r" % (self._deque,)
+        self._count('objects_queued', len(result))
         print "pending = %r" % (self._pending,)
         self._pending.update(map(lambda x: x[0], result))
         print "pending after = %r" % (self._pending,)
-- 
2.45.2