From 039049f6d1dd7e2d903578c340f7b63028c3f364 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 20 Apr 2015 17:54:17 +0100 Subject: [PATCH] Add ignore mechanism to upload callback. Signed-off-by: Daira Hopwood --- src/allmydata/frontends/drop_upload.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index f944e6b0..61668b00 100644 --- a/src/allmydata/frontends/drop_upload.py +++ b/src/allmydata/frontends/drop_upload.py @@ -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() -- 2.45.2