From b52f8a9b99d0f1936ef9cd121603f17ce93acd20 Mon Sep 17 00:00:00 2001 From: lou Date: Tue, 11 Aug 2026 14:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=85=A5=E5=8F=A3=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C:=20=E8=B7=AF=E5=BE=84=E5=BF=85=E9=A1=BB=E6=98=AF?= =?UTF-8?q?=E6=96=87=E4=BB=B6=20(=E7=9B=AE=E5=BD=95=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=94=A8=20sz-backup=20=E5=A4=87=E4=BB=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - metadata.py main: exists 后补 is_file 检查, 目录直接中文报错退出 - _build_vol_init 库函数内防御: 非文件抛 ValueError - 修复: TUI 上传目录 (/home/lou/图片/) 时 IsADirectoryError traceback --- metadata.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/metadata.py b/metadata.py index 9913390..9c371b2 100644 --- a/metadata.py +++ b/metadata.py @@ -148,6 +148,8 @@ def _build_vol_init(src_path: Path, args: argparse.Namespace) -> int: workdir = Path(tempfile.gettempdir()) init_path = src_path.with_name(src_path.name + ".init.json") manifest_path = src_path.with_name(src_path.name + "_manifest.json") + if not src_path.is_file(): + raise ValueError(f"源路径不是文件 (目录请用备份流程): {src_path}") src_st = src_path.stat().st_size print(f"=== 卷压缩模式: {src_path.name} ({src_st / 1048576:.1f} MB), 每卷 {args.vol_compress} MB ===") chunks: list[dict[str, Any]] = [] @@ -247,6 +249,9 @@ def main() -> int: if not src_path.exists(): print(f"[错误] 文件不存在: {src_path}") return 1 + if not src_path.is_file(): + print(f"[错误] 不是文件 (目录上传请用 sz-backup 一键备份): {src_path}") + return 1 # 卷压缩模式: 流式切卷 -> 逐卷 7z 压缩 -> 逐卷加密 (每卷内存 16MB 级, 规避大文件 OOM) if args.vol_compress > 0: