From: David Stainton Date: Mon, 20 Apr 2015 22:34:33 +0000 (+0100) Subject: WIP X-Git-Url: https://git.rkrishnan.org/junkers?a=commitdiff_plain;h=2d051bef7fcb94e3a9fd8f2d275e2ac772535fb7;p=tahoe-lafs%2Ftahoe-lafs.git WIP --- diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index 8c6d0ba9..7c3e48e9 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) @@ -153,6 +158,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 4ab434f2..9cfe6508 100644 --- a/src/allmydata/test/test_drop_upload.py +++ b/src/allmydata/test/test_drop_upload.py @@ -137,43 +137,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