Repository navigation
fix(cli): backup create 在开始前检查 --out:文件夹里写默认名,非 .zip 扩展名按用法错误拒绝 - #1135
Merged
Merged
Conversation
--out 是已有的文件夹(或没有扩展名)时,在里面写 weflow-backup-YYYYMMDD-HHMMSS.zip,缺少的文件夹会先建好;扩展名不是 .zip 时在读账号之前按用法错误拒绝。原来给已有文件夹时要等整个备份打包完才在改名时失败,给 .txt 等扩展名照样写出 zip。结果的 out 是实际写入的路径,「move the backup to」的报错加进中文目录。 fixed #1134 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
做了什么
fixed #1134
backup create --out原来不检查输出路径。给一个已有的文件夹时,要等整个备份打包完,才在最后改名时失败,报错的前半句还是英文。给.txt等其他扩展名时,照样写出一个 zip。现在开始备份前、读账号之前,先在 CLI 层检查--out:--out是已有的文件夹(不管名字里有没有点)或没有扩展名:在里面写weflow-backup-YYYYMMDD-HHMMSS.zip(本地时间),文件夹不存在时先建好。--out是.zip文件(不分大小写):照原样写这个文件,缺少的上级文件夹先建好。invalid_arguments,退出码 2,HTTP 400),报错是a backup is a zip: give --out a folder or a .zip file,中文为「备份是 zip 文件:--out 请给文件夹或 .zip 文件」。具体改动:
files.rs:新增backup_target,与zip_target共用判断扩展名的zip_in。zip_target的行为不变。与zip_target不同的是,已有的文件夹先算作文件夹,所以backups.2025这样带点的文件夹也能用。out是实际写入的路径。契约里BackupCreated.out的说明随之改写,已重新生成web/contract的快照和contract.gen.ts。只改了说明,字段没有变。--out的帮助改为「Output: a .zip file, or a folder to write weflow-backup-YYYYMMDD-HHMMSS.zip into」,同步加了中文帮助。messages_zh:加入新的用法错误,以及move the backup to {}: {}的中文(真正的 I/O 失败时仍会出现)。WebUI 的备份用
?return=file,服务端给的路径是.zip,不受影响。验证
files::tests::a_backup_goes_to_a_zip_file_or_into_a_folder:覆盖已有文件夹、带点的文件夹、名为old.zip的文件夹、没有扩展名的新路径、.zip和.ZIP,以及.txt、.json、.zip.bak被拒绝的情况。usage::a_backup_goes_into_a_folder_and_not_under_another_extension:--out backup.txt在命令行(文本和--json两种输出)和POST /backup/create上都是用法错误,文件没有写出;--out <已有文件夹>在命令行和 API 上都写进文件夹,out返回weflow-backup-*.zip,文件夹里没有残留的.weflow-partial。cargo clippy -p weflow-cli -p weflow-core --all-targets -- -D warnings、cargo fmt --check、cargo test -p weflow-cli(包括契约快照)、cargo test -p weflow-core --lib messages_zh、bun run contract、bun run typecheck全部通过。用户可见的行为
有变化:
weflow-backup-<时间>.zip。--out mybackup),原来写出名为mybackup的 zip 文件,现在建mybackup/文件夹并在里面写默认名,与export --zip一致。.zip但上级文件夹不存在,原来报「创建失败」,现在先建好上级文件夹。API 的路由、参数和响应字段都没有变,不提升 API 版本。Wiki 的备份页和故障排查已按新行为同步。
🤖 Generated with Claude Code