From 0bcbc0bf575fe16a2d976b540a590aa8d579c0cd Mon Sep 17 00:00:00 2001 From: David Stainton Date: Mon, 20 Apr 2015 23:34:33 +0100 Subject: [PATCH] WIP --- src/allmydata/frontends/drop_upload.py | 6 ++++++ src/allmydata/test/no_network.py | 4 ++-- src/allmydata/test/test_drop_upload.py | 24 +++++++++++------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index ca900191..a482caf7 100644 --- a/src/allmydata/frontends/drop_upload.py +++ b/src/allmydata/frontends/drop_upload.py @@ -38,6 +38,8 @@ class DropUploader(service.MultiService): "could not be represented in the filesystem encoding." % quote_output(local_dir_utf8)) + self._objid = None + self._classname = 'DropUploader' self._pending = set() self._client = client self._stats_provider = client.stats_provider @@ -91,6 +93,7 @@ class DropUploader(service.MultiService): return not r.was_uploaded() def _scan(self, localpath): + print "_scan" if not os.path.isdir(localpath): raise AssertionError("Programmer error: _scan() must be passed a directory path.") quoted_path = quote_local_unicode_path(localpath) @@ -112,12 +115,14 @@ class DropUploader(service.MultiService): if islink: self.warn("WARNING: cannot backup symlink %s" % quote_local_unicode_path(childpath)) elif isdir: + print "isdir" # recurse on the child directory self._scan(childpath) must_upload = self._check_db_file(childpath) if must_upload: self._append_to_deque(childpath) elif isfile: + print "isfile" must_upload = self._check_db_file(childpath) if must_upload: self._append_to_deque(childpath) @@ -158,6 +163,7 @@ class DropUploader(service.MultiService): self._turn_deque() def _append_to_deque(self, path): + print "_append_to_deque" self._upload_deque.append(path) self._pending.add(path) self._stats_provider.count('drop_upload.objects_queued', 1) diff --git a/src/allmydata/test/no_network.py b/src/allmydata/test/no_network.py index ee7a049a..6c50bb17 100644 --- a/src/allmydata/test/no_network.py +++ b/src/allmydata/test/no_network.py @@ -175,8 +175,8 @@ class NoNetworkStorageBroker: class NoNetworkClient(Client): - def disownParentService(self): - pass + def disownServiceParent(self): + self.disownServiceParent() def create_tub(self): pass def init_introducer_client(self): diff --git a/src/allmydata/test/test_drop_upload.py b/src/allmydata/test/test_drop_upload.py index 92b2a918..afbc3a49 100644 --- a/src/allmydata/test/test_drop_upload.py +++ b/src/allmydata/test/test_drop_upload.py @@ -138,43 +138,41 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA def _test_persistence(self): self.uploader = None self.dir_node = None - self.set_up_grid() self.local_dir = os.path.join(self.basedir, u"test_persistence") self.mkdir_nonascii(self.local_dir) - self.client = self.g.clients[0] self.stats_provider = self.client.stats_provider - d = self.client.create_dirnode() d.addCallback(self._made_upload_dir) - d.addCallback(lambda ign: self.uploader.Pause()) + d.addCallback(self._cleanup) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 0)) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0)) + d.addCallback(lambda ign: self.client.removeService(self.uploader)) + + def msg(val): + print "old uploader removed" + return None + d.addCallback(msg) + def create_file(val): myFile = os.path.join(self.local_dir, "what") f = open(myFile, "wb") f.write("meow") f.close() - # XXX - #self.notify_close_write(FilePath(myFile)) + print "test file created" return None d.addCallback(create_file) - d.addCallback(self._cleanup) - #d.addCallback(lambda ign: self.client.stopService()) - #d.addCallback(lambda ign: self.client.disownParentService(self)) - #d.addCallback(lambda ign: self.client.startService()) + d.addCallback(self._made_upload_dir) - def resume_uploader(val): - self.uploader.Resume() + print "created new uploader" d = defer.Deferred() self.uploader.set_uploaded_callback(d.callback) return d d.addCallback(resume_uploader) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0)) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 1)) - d.addBoth(self._cleanup) return d -- 2.45.2