コード例 #1
0
ファイル: server.py プロジェクト: irinatoma/MagicFolder
class Archive(object):
    def __init__(self, root_path):
        assert path.isdir(root_path)
        self.root_path = root_path
        self.data_pool = BlobDB(path.join(root_path, 'objects'))

    def open_version_read(self, n):
        return open(path.join(self.root_path, 'versions/%d' % n), 'rb')

    def open_version_write(self, n):
        return open(path.join(self.root_path, 'versions/%d' % n), 'wb')

    def get_latest_version(self):
        versions_path = path.join(self.root_path, 'versions')
        return max(int(v) for v in os.listdir(versions_path))

    def __contains__(self, checksum):
        return checksum in self.data_pool

    def read_file(self, checksum):
        return self.data_pool.read_file(checksum)

    def write_file(self, checksum):
        return self.data_pool.write_file(checksum)
コード例 #2
0
ファイル: server.py プロジェクト: irinatoma/MagicFolder
 def __init__(self, root_path):
     assert path.isdir(root_path)
     self.root_path = root_path
     self.data_pool = BlobDB(path.join(root_path, 'objects'))