上传入口校验: 路径必须是文件 (目录报错提示用 sz-backup 备份)

- metadata.py main: exists 后补 is_file 检查, 目录直接中文报错退出
- _build_vol_init 库函数内防御: 非文件抛 ValueError
- 修复: TUI 上传目录 (/home/lou/图片/) 时 IsADirectoryError traceback
This commit is contained in:
lou
2026-08-11 14:39:17 +08:00
parent bb1699e9fd
commit b52f8a9b99
+5
View File
@@ -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: