]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add ignore mechanism to upload callback.
authorDaira Hopwood <daira@jacaranda.org>
Mon, 20 Apr 2015 16:54:17 +0000 (17:54 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 18:45:15 +0000 (19:45 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/drop_upload.py

index f944e6b098b89b9eb9ed63054e0788d3be8d3571..61668b00a240ab69eff98cc93fdbeca3fd708277 100644 (file)
@@ -69,6 +69,7 @@ class DropUploader(service.MultiService):
             raise AssertionError("The URI in 'private/drop_upload_dircap' is not a writecap to a directory.")
 
         self._uploaded_callback = lambda ign: None
+        self._ignore_count = 0
 
         self._notifier = inotify.INotify()
         if hasattr(self._notifier, 'set_pending_delay'):
@@ -240,13 +241,22 @@ class DropUploader(service.MultiService):
                 return None
 
         d.addCallbacks(_succeeded, _failed)
-        d.addBoth(self._uploaded_callback)
-
+        d.addBoth(self._do_upload_callback)
         return d
 
-    def set_uploaded_callback(self, callback):
-        """This sets a function that will be called after a file has been uploaded."""
+    def _do_upload_callback(self, res):
+        print "in _do_upload_callback"
+        if self._ignore_count == 0:
+            self._uploaded_callback(res)
+        else:
+            self._ignore_count -= 1
+
+    def set_uploaded_callback(self, callback, ignore_count=0):
+        """
+        This sets a function that will be called after a file has been uploaded.
+        """
         self._uploaded_callback = callback
+        self._ignore_count = ignore_count
 
     def finish(self, for_tests=False):
         self._notifier.stopReading()