[tahoe-lafs-trac-stream] [tahoe-lafs] #393: mutable: implement MDMF

tahoe-lafs trac at tahoe-lafs.org
Thu Mar 3 10:25:29 PST 2011


#393: mutable: implement MDMF
------------------------------+---------------------------------------------
     Reporter:  warner        |       Owner:  kevan                                                                                                                 
         Type:  enhancement   |      Status:  assigned                                                                                                              
     Priority:  major         |   Milestone:  1.9.0                                                                                                                 
    Component:  code-mutable  |     Version:  1.0.0                                                                                                                 
   Resolution:                |    Keywords:  newcaps performance random-access privacy gsoc mdmf mutable backward-compatibility forward-compatibility review-needed
Launchpad Bug:                |  
------------------------------+---------------------------------------------

Comment (by warner):

 I found another bug in the handling of {{{offset=0}}} which, when used to
 replace the first few bytes of a file through the webapi, caused the file
 to be truncated instead. Here's a test:
 {{{
 --- old-trunk-393-s39/src/allmydata/test/test_mutable.py        2011-03-03
 10:17:21.000000000 -0800
 +++ new-trunk-393-s39/src/allmydata/test/test_mutable.py        2011-03-03
 10:17:21.000000000 -0800
 @@ -2978,6 +2978,17 @@
              self.failUnlessEqual(results, new_data))
          return d

 +    def test_replace_beginning(self):
 +        # We should be able to replace data at the beginning of the file
 +        # without truncating the file
 +        B = "beginning"
 +        new_data = B + self.data[len(B):]
 +        d = self.mdmf_node.get_best_mutable_version()
 +        d.addCallback(lambda mv: mv.update(MutableData(B), 0))
 +        d.addCallback(lambda ignored:
 self.mdmf_node.download_best_version())
 +        d.addCallback(lambda results: self.failUnlessEqual(results,
 new_data))
 +        return d
 +
      def test_replace_segstart1(self):
          offset = 128*1024+1
          new_data = "NNNN"
 --- old-trunk-393-s39/src/allmydata/test/test_web.py    2011-03-03
 10:17:27.000000000 -0800
 +++ new-trunk-393-s39/src/allmydata/test/test_web.py    2011-03-03
 10:17:27.000000000 -0800
 @@ -3182,6 +3182,12 @@
          d.addCallback(_get_data)
          d.addCallback(lambda results:
              self.failUnlessEqual(results, self.new_data + ("puppies" *
 100)))
 +        # and try replacing the beginning of the file
 +        d.addCallback(lambda ignored:
 +            self.PUT("/uri/%s?offset=0" % self.filecap, "begin"))
 +        d.addCallback(_get_data)
 +        d.addCallback(lambda results:
 +            self.failUnlessEqual(results,
 "begin"+self.new_data[len("begin"):]+("puppies"*100)))
          return d

      def test_PUT_update_at_invalid_offset(self):
 }}}

 In web/filenode.py I'd suggest using "None" instead of "False" to mean "no
 offset= argument was provided", and I'd strongly recommend using "{{{x is
 None}}}" instead of e.g. "{{{x == None}}}". I'm pretty sure the bug hit by
 that test_web.py test is the result of comparing "{{{0 == False}}}" (which
 is true, whereas "{{{0 is False}}}" is not). The test_mutable code passes,
 but the test_web code fails, so I think the problem is in the webapi layer
 and not in the {{{MutableFileNode}}} layer.

 Also, the code in {{{Publish.setup_encoding_parameters}}} which calculates
 {{{self.starting_segment}}} .. could you replace that
 {{{div_ceil}}}+corrections with a simple integer divide?
 {{{self.starting_segment = offset // segmentsize}}} ? I think that's
 equivalent to what it's currently trying to do, and probably easier to
 maintain.

-- 
Ticket URL: <http://tahoe-lafs.org/trac/tahoe-lafs/ticket/393#comment:86>
tahoe-lafs <http://tahoe-lafs.org>
secure decentralized storage


More information about the tahoe-lafs-trac-stream mailing list