aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2024-03-29 18:39:19 +0800
committer苏向夜 <fu050409@163.com>2024-03-29 18:39:19 +0800
commit7815042a0ff4bf71f390dcdb6e0d01b081b2a89f (patch)
treeffb91b3b55cd0e1e79bf69d73e748b3ef101cd61
parentd80fe58683dfa331de28f0d382d8fdf1931b4f5b (diff)
downloadipm-7815042a0ff4bf71f390dcdb6e0d01b081b2a89f.tar.gz
ipm-7815042a0ff4bf71f390dcdb6e0d01b081b2a89f.zip
feat(freeze): remove extract outputs
-rw-r--r--src/ipm/utils/freeze.py18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/ipm/utils/freeze.py b/src/ipm/utils/freeze.py
index 063d74e..1a3dd5c 100644
--- a/src/ipm/utils/freeze.py
+++ b/src/ipm/utils/freeze.py
@@ -62,44 +62,32 @@ def build_ipk(ipk: InfiniProject, echo: bool = False) -> InfiniFrozenPackage:
def extract_ipk(
- source_path: StrPath, dist_path: StrPath, hash: Optional[str], echo: bool = False
+ source_path: StrPath,
+ dist_path: StrPath,
+ hash: Optional[str] = None,
) -> Optional[InfiniProject]:
ifp_path = Path(source_path).resolve()
dist_path = Path(dist_path).resolve()
- update("文件校验...", echo)
if hash and not ifp_verify(ifp_path, hash):
raise VerifyFailed("文件完整性验证失败!")
- success("文件校验成功.", echo)
temp_dir = tempfile.TemporaryDirectory()
temp_path = Path(temp_dir.name).resolve() / "ifp"
- info(f"创建临时目录 [blue]{temp_dir}[/blue].", echo)
- update(f"解压 [blue]{ifp_path}[/blue]...", echo)
_freeze.extract_tar_gz(str(ifp_path), str(temp_path))
arc_path = next(temp_path.iterdir())
temp_pkg = InfiniProject(arc_path)
dist_pkg_path = dist_path.joinpath(temp_pkg.default_name)
- success(
- f"[bold green]{temp_pkg.name}[/bold green] [yellow]{temp_pkg.version}[/yellow] 已解压至缓存目录.",
- echo,
- )
if dist_pkg_path.exists():
- update("目标路径已存在, 清理旧文件...", echo)
try:
shutil.rmtree(dist_pkg_path)
except Exception as err:
return error(str(err))
- success("旧规则包项目文件清理完毕.", echo)
- update(f"迁移文件至目标目录...", echo)
shutil.move(arc_path, dist_path)
- success(f"文件已迁移至 [blue]{dist_pkg_path}[/blue].", echo)
- update(f"清理临时文件...", echo)
temp_dir.cleanup()
- success(f"临时文件清理完毕.", echo)
return InfiniProject(dist_pkg_path)