def archive(self, archive_path: str, extract_path: str) -> None: SUDO.folder_assert(extract_path) archive_temp = make_temp_path("zip-archive-temp") SUDO.parent_ensure(archive_temp) zipper = CmdZip() zipper.with_archive(archive_temp) zipper.with_extract(extract_path) zipper.execute_unit_sert() SUDO.files_move(archive_temp, archive_path)
def archive(self, archive_path: str, extract_path: str) -> None: SUDO.folder_assert(extract_path) archive_temp = make_temp_path("zip-archive-temp") SUDO.parent_ensure(archive_temp) tar = Tar() tar.with_archive(archive_temp) tar.with_extract(extract_path) tar.with_packer(archive_path) tar.with_make_pack() # keep last tar.execute_unit_sert() SUDO.files_move(archive_temp, archive_path)
def remote_head(self, remote_url: str) -> Mapping[str, str]: logger.debug(f"http.head.fetch: {remote_url}") header_path = make_temp_path("curl-head") SUDO.parent_ensure(header_path) curl = Curl() with_auth_url(curl, remote_url) with_proxy_config(curl, remote_url) curl.with_file_head(header_path) curl.execute_unit_sert() header_dict = parse_header_file(header_path) SUDO.files_delete(header_path) return header_dict
def archive(self, archive_path: str, extract_path: str) -> None: logger.debug(f"pack.archive.tar: {extract_path}") SUDO.folder_assert(extract_path) archive_temp = make_temp_path("tar-archive-temp") SUDO.parent_ensure(archive_temp) tar = Tar() tar.with_archive(archive_temp) tar.with_extract(extract_path) tar.with_packer(archive_path) tar.with_make_pack() # keep last tar.execute_unit_sert() SUDO.files_move(archive_temp, archive_path) synchronize_header(extract_path, archive_path)
def get(self, local_url: str, remote_url: str) -> None: "fetch remote resource and persist headers in xattr" logger.debug(f"http.get.fetch: {remote_url}") local, remote = self.parse(local_url, remote_url) header_path = make_temp_path("curl-head") source_path = make_temp_path("curl-gets") target_path = local.path SUDO.parent_ensure(header_path) curl = Curl() with_auth_url(curl, remote_url) with_proxy_config(curl, remote_url) curl.with_file_get(source_path) curl.with_dump_header(header_path) curl.execute_unit_sert() header_dict = parse_header_file(header_path) SUDO.files_delete(header_path) SUDO.files_move(source_path, target_path) # TODO attr SUDO.xattr_save(target_path, header_dict)