[tahoe-dev] [tahoe-lafs] #993: refactor download interfaces to treat immutable files and mutable versions more uniformly

tahoe-lafs trac at tahoe-lafs.org
Wed Jul 7 00:10:59 UTC 2010


#993: refactor download interfaces to treat immutable files and mutable versions
more uniformly
------------------------------+---------------------------------------------
     Reporter:  davidsarah    |       Owner:  warner                                
         Type:  enhancement   |      Status:  new                                   
     Priority:  major         |   Milestone:  1.8.0                                 
    Component:  code-mutable  |     Version:  1.6.0                                 
   Resolution:                |    Keywords:  cleanup download mutable review-needed
Launchpad Bug:                |  
------------------------------+---------------------------------------------

Comment (by davidsarah):

 [source:src/allmydata/frontends/sftpd.py at 4521#L706 Here] is an example of
 code that forks depending on whether it's downloading a mutable or
 immutable file, in the SFTP frontend:

 {{{
     # TODO: use download interface described in #993 when implemented.
     if filenode.is_mutable():
         self.async.addCallback(lambda ign:
 filenode.download_best_version())
         def _downloaded(data):
             self.consumer = OverwriteableFileConsumer(len(data),
 tempfile_maker)
             self.consumer.write(data)
             self.consumer.finish()
             return None
         self.async.addCallback(_downloaded)
     else:
         download_size = filenode.get_size()
         assert download_size is not None, "download_size is None"
         self.consumer = OverwriteableFileConsumer(download_size,
 tempfile_maker)
         def _read(ign):
             if noisy: self.log("_read immutable", level=NOISY)
             filenode.read(self.consumer, 0, None)
         self.async.addCallback(_read)
 }}}

 With the proposed interface it could be:

 {{{
     self.async.addCallback(lambda ign: filenode.get_best_version())
     def _got_best_version(version):
         if noisy: self.log("_got_best_version(%r)" % (version,),
 level=NOISY)
         download_size = version.get_size()
         assert download_size is not None, "download_size is None"
         self.consumer = OverwriteableFileConsumer(download_size,
 tempfile_maker)
         version.read(self.consumer, 0, None)
     self.async.addCallback(_got_best_version)
 }}}

 Since the new downloader is milestone 1.8, this can wait until after
 1.7.1, though.

-- 
Ticket URL: <http://tahoe-lafs.org/trac/tahoe-lafs/ticket/993#comment:5>
tahoe-lafs <http://tahoe-lafs.org>
secure decentralized file storage grid


More information about the tahoe-dev mailing list