예제 #1
0
    def delete_package(self, pkg_name: str, top_hash: str = None):
        package_path = self.pointers_dir(pkg_name)
        paths = list(list_url(package_path))
        if not paths:
            raise QuiltException(
                "No such package exists in the given directory.")

        if top_hash is not None:
            top_hash = self.resolve_top_hash(pkg_name, top_hash)
            deleted = []
            remaining = []
            for path, _ in paths:
                pkg_hash = get_bytes(self.pointer_pk(pkg_name, path)).decode()
                (deleted if pkg_hash == top_hash else remaining).append(path)
            if not deleted:
                raise QuiltException(
                    "No such package version exists in the given directory.")
            for path in deleted:
                delete_url(self.pointer_pk(pkg_name, path))
            if 'latest' in deleted and remaining:
                # Create a new "latest". Technically, we need to compare numerically,
                # but string comparisons will be fine till year 2286.
                new_latest = max(remaining)
                copy_file(self.pointer_pk(pkg_name, new_latest),
                          self.pointer_latest_pk(pkg_name))
        else:
            for path, _ in paths:
                delete_url(self.pointer_pk(pkg_name, path))
예제 #2
0
파일: base.py 프로젝트: quiltdata/quilt
 def delete_package_version(self, pkg_name: str, top_hash: str):
     delete_url(self.manifest_pk(pkg_name, top_hash))
     if get_bytes(self.pointer_latest_pk(pkg_name)).decode() == top_hash:
         delete_url(self.pointer_latest_pk(pkg_name))
         timestamp, new_latest = max(self.list_package_versions_with_timestamps(pkg_name), default=(None, None))
         if new_latest:
             put_bytes(new_latest.encode(), self.pointer_latest_pk(pkg_name))
     for pointer, pointer_top_hash in self.list_package_pointers(pkg_name):
         if pointer_top_hash == top_hash:
             delete_url(self.pointer_pk(pkg_name, pointer))
예제 #3
0
파일: s3.py 프로젝트: ltirrell/quilt
 def list_package_pointers(self, pkg_name: str):
     package_dir = self.pointers_dir(pkg_name)
     for path, _ in list_url(package_dir):
         pkg_hash = get_bytes(package_dir.join(path))
         yield path, pkg_hash.decode().strip()