]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
WIP
authorDavid Stainton <dstainton415@gmail.com>
Mon, 20 Apr 2015 22:34:33 +0000 (23:34 +0100)
committerDavid Stainton <dstainton415@gmail.com>
Mon, 20 Apr 2015 22:34:33 +0000 (23:34 +0100)
src/allmydata/frontends/drop_upload.py
src/allmydata/test/no_network.py
src/allmydata/test/test_drop_upload.py

index 8c6d0ba96455af5eb77b8c0797e779bba4ef8110..7c3e48e95acdf57107938b9c047bc77c69e7186f 100644 (file)
@@ -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)
index ee7a049abbb4b310b2d6542fc433a40d34e4ffa5..6c50bb17447521fc443b1422f73cf8e016b97789 100644 (file)
@@ -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):
index 4ab434f236294538e57e3a93d36146c02ffa8aed..9cfe6508d881c788a1f212732be724b347142493 100644 (file)
@@ -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