示例#1
0
def create_archive(cache_dir, uri):
    """ Create a new archive. """
    block_dir = setup_block_dir(cache_dir, uri)

    tmps = HandleTemps(os.path.join(cache_dir, TMP_DIR))
    archive = WORMBlockArchive(DeltaCoder(), BlockStorage(tmps))
    archive.create(block_dir, BLOCK_NAME)

    return archive
示例#2
0
def create_archive(cache_dir, uri):
    """ Create a new archive. """
    block_dir = setup_block_dir(cache_dir, uri)

    tmps = HandleTemps(os.path.join(cache_dir, TMP_DIR))
    archive = WORMBlockArchive(DeltaCoder(), BlockStorage(tmps))
    archive.create(block_dir, BLOCK_NAME)

    return archive
示例#3
0
def load_cached_archive(cache_dir, uri):
    """ Load an archive from the cache. """
    top_key = load_cached_top_key(cache_dir, uri)
    if len(top_key[1]) != 1 or top_key[1][0][1] != KIND_MANIFEST:
        raise Exception("Can't read manifest from archive.")

    verify_fully_cached(cache_dir, uri, top_key)

    # Clear previous block dir and copy cached blocks into it.
    block_dir = setup_block_dir(cache_dir, uri, top_key, True)

    tmps = HandleTemps(os.path.join(cache_dir, TMP_DIR))
    archive = WORMBlockArchive(DeltaCoder(), BlockStorage(tmps))
    archive.load(block_dir, BLOCK_NAME)

    # IMPORTANT: Set tags so we can keep track of
    #            unchanged blocks.
    for index in range(0, len(top_key[0])):
        archive.blocks.tags[index] = str(index)

    return top_key, archive
示例#4
0
def load_cached_archive(cache_dir, uri):
    """ Load an archive from the cache. """
    top_key = load_cached_top_key(cache_dir, uri)
    if len(top_key[1]) != 1 or top_key[1][0][1] != KIND_MANIFEST:
        raise Exception("Can't read manifest from archive.")

    verify_fully_cached(cache_dir, uri, top_key)

    # Clear previous block dir and copy cached blocks into it.
    block_dir = setup_block_dir(cache_dir, uri, top_key, True)

    tmps = HandleTemps(os.path.join(cache_dir, TMP_DIR))
    archive = WORMBlockArchive(DeltaCoder(), BlockStorage(tmps))
    archive.load(block_dir, BLOCK_NAME)

    # IMPORTANT: Set tags so we can keep track of
    #            unchanged blocks.
    for index in range(0, len(top_key[0])):
        archive.blocks.tags[index] = str(index)

    return top_key, archive
示例#5
0
    def load_archive(self, block_name):
        archive = WORMBlockArchive(DeltaCoder(), BlockStorage(self.tmps))
        archive.load(self.test_dir, block_name)

        return archive
示例#6
0
    def make_empty_archive(self, block_name):
        archive = WORMBlockArchive(DeltaCoder(), BlockStorage(self.tmps))

        archive.create(self.test_dir, block_name)

        return archive
示例#7
0
    def load_archive(self, block_name):
        archive = WORMBlockArchive(DeltaCoder(), BlockStorage(self.tmps))
        archive.load(self.test_dir, block_name)

        return archive
示例#8
0
    def make_empty_archive(self, block_name):
        archive = WORMBlockArchive(DeltaCoder(), BlockStorage(self.tmps))

        archive.create(self.test_dir, block_name)

        return archive