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
def load_archive(self, block_name): archive = WORMBlockArchive(DeltaCoder(), BlockStorage(self.tmps)) archive.load(self.test_dir, block_name) return archive