Example #1
0
 def __init__(self,
              allow_writes,
              node_size,
              codec,
              dirname=None,
              upload_max=1024,
              lru_size=500,
              vfs=None,
              format=None):
     tracing.trace('new NodeStoreDisk: %s', dirname)
     assert dirname is not None
     if format is not None:
         tracing.trace('forcing format_base: %s', format)
         self.format_base = format
     larch.NodeStore.__init__(self,
                              allow_writes=allow_writes,
                              node_size=node_size,
                              codec=codec)
     self.dirname = dirname
     self.metadata_name = os.path.join(dirname, 'metadata')
     self.metadata = None
     self.rs = larch.RefcountStore(self)
     self.cache_size = lru_size
     self.cache = larch.LRUCache(self.cache_size)
     self.upload_max = upload_max
     self.upload_queue = larch.UploadQueue(self._really_put_node,
                                           self.upload_max)
     self.vfs = vfs if vfs != None else LocalFS()
     self.journal = larch.Journal(allow_writes, self.vfs, dirname)
     self.idpath = larch.IdPath(os.path.join(dirname, self.nodedir),
                                DIR_DEPTH, DIR_BITS, DIR_SKIP)
Example #2
0
 def test_partial_commit_finished_by_new_instance(self):
     filename = self.join('foo/bar')
     metadata = self.join('metadata')
     self.j.overwrite_file(filename, 'bar')
     self.j.overwrite_file(metadata, '')
     self.j.commit(skip=[filename])
     
     j2 = larch.Journal(True, self.fs, self.tempdir)
     self.assertTrue(j2.exists(filename))
Example #3
0
 def setUp(self):
     self.tempdir = tempfile.mkdtemp()
     self.fs = larch.LocalFS()
     self.j = larch.Journal(True, self.fs, self.tempdir)
Example #4
0
 def test_unflagged_commit_means_new_instance_rollbacks(self):
     filename = self.join('foo/bar')
     self.j.overwrite_file(filename, 'bar')
     
     j2 = larch.Journal(True, self.fs, self.tempdir)
     self.assertFalse(j2.exists(filename))