]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Let Uploader retain History instead of passing it into upload(). Fixes #1079.
authorBrian Warner <warner@lothar.com>
Mon, 29 Aug 2011 06:32:46 +0000 (23:32 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 29 Aug 2011 06:32:46 +0000 (23:32 -0700)
This consistently records all immutable uploads in the Recent Uploads And
Downloads page, regardless of code path. Previously, certain webapi upload
operations (like PUT /uri/$DIRCAP/newchildname) failed to pass the History
object and were left out.

src/allmydata/client.py
src/allmydata/immutable/upload.py
src/allmydata/nodemaker.py
src/allmydata/test/test_web.py

index b030867bc19ef6a293df02bd42c030a401cf4e30..ed0ff9a096d2a67ab0c2f5be184c67c59f027472 100644 (file)
@@ -278,7 +278,8 @@ class Client(node.Node, pollmixin.PollMixin):
         self.history = History(self.stats_provider)
         self.terminator = Terminator()
         self.terminator.setServiceParent(self)
-        self.add_service(Uploader(helper_furl, self.stats_provider))
+        self.add_service(Uploader(helper_furl, self.stats_provider,
+                                  self.history))
         self.init_stub_client()
         self.init_blacklist()
         self.init_nodemaker()
@@ -513,4 +514,4 @@ class Client(node.Node, pollmixin.PollMixin):
 
     def upload(self, uploadable):
         uploader = self.getServiceNamed("uploader")
-        return uploader.upload(uploadable, history=self.get_history())
+        return uploader.upload(uploadable)
index 1a573184d872c7354f0f025eb93dd447af7a6db5..013aca97cbc6a9ce2c221531cc9e444f5bfdd33e 100644 (file)
@@ -1409,9 +1409,10 @@ class Uploader(service.MultiService, log.PrefixingLogMixin):
     name = "uploader"
     URI_LIT_SIZE_THRESHOLD = 55
 
-    def __init__(self, helper_furl=None, stats_provider=None):
+    def __init__(self, helper_furl=None, stats_provider=None, history=None):
         self._helper_furl = helper_furl
         self.stats_provider = stats_provider
+        self._history = history
         self._helper = None
         self._all_uploads = weakref.WeakKeyDictionary() # for debugging
         log.PrefixingLogMixin.__init__(self, facility="tahoe.immutable.upload")
@@ -1447,7 +1448,7 @@ class Uploader(service.MultiService, log.PrefixingLogMixin):
         return (self._helper_furl, bool(self._helper))
 
 
-    def upload(self, uploadable, history=None):
+    def upload(self, uploadable):
         """
         Returns a Deferred that will fire with the UploadResults instance.
         """
@@ -1483,8 +1484,8 @@ class Uploader(service.MultiService, log.PrefixingLogMixin):
                     d2.addCallback(lambda x: uploader.start(eu))
 
                 self._all_uploads[uploader] = None
-                if history:
-                    history.add_upload(uploader.get_upload_status())
+                if self._history:
+                    self._history.add_upload(uploader.get_upload_status())
                 def turn_verifycap_into_read_cap(uploadresults):
                     # Generate the uri from the verifycap plus the key.
                     d3 = uploadable.get_encryption_key()
index b70ed601ad748e81581f51ecee28f2c57db64c79..5d46d893cadca774ec81423c407376a72a6bd7b1 100644 (file)
@@ -137,7 +137,7 @@ class NodeMaker:
             convergence = self.secret_holder.get_convergence_secret()
         packed = pack_children(children, None, deep_immutable=True)
         uploadable = Data(packed, convergence)
-        d = self.uploader.upload(uploadable, history=self.history)
+        d = self.uploader.upload(uploadable)
         d.addCallback(lambda results: self.create_from_cap(None, results.uri))
         d.addCallback(self._create_dirnode)
         return d
index b964c7fefc0034b3fd2e1696a4432b077eeaace9..3a115ba8ccc993b9b7f596deb4c9dbf0cb0d647a 100644 (file)
@@ -69,7 +69,7 @@ class FakeNodeMaker(NodeMaker):
 
 class FakeUploader(service.Service):
     name = "uploader"
-    def upload(self, uploadable, history=None):
+    def upload(self, uploadable):
         d = uploadable.get_size()
         d.addCallback(lambda size: uploadable.read(size))
         def _got_data(datav):