From 4839c19155d498ee3f25fc4b0009939c94065e67 Mon Sep 17 00:00:00 2001 From: Iven Hsu Date: Tue, 10 Feb 2026 11:27:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=20Target=20outputs=20?= =?UTF-8?q?=E4=B8=AD=E4=BD=BF=E7=94=A8=E9=80=9A=E9=85=8D=E7=AC=A6=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 Archiver.archive 方法中使用 glob.glob() 展开通配符, 类似 shell 在调用 tar 之前展开通配符的行为。 如果通配符未匹配到任何文件,抛出 FileNotFoundError。 --- src/quack/utils/archiver.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/quack/utils/archiver.py b/src/quack/utils/archiver.py index 1b0f98f..8d1549a 100644 --- a/src/quack/utils/archiver.py +++ b/src/quack/utils/archiver.py @@ -2,6 +2,7 @@ from __future__ import annotations +import glob import hashlib import os import shutil @@ -22,7 +23,13 @@ def archive(paths: Iterable[str], archive_path: str) -> None: try: with tarfile.open(tmp_tar_path, "w") as tar: for path in paths: - tar.add(path, arcname=path) + # 展开通配符 + matches = glob.glob(path) + if not matches: + raise FileNotFoundError(f"未找到匹配的文件:{path}") + + for matched_path in matches: + tar.add(matched_path, arcname=matched_path) with open(tmp_tar_path, "rb") as f_in: tar_data = f_in.read()