feat(backup): 新增按需(选择性)文件恢复#91
Merged
Merged
Conversation
在内容浏览基础上支持只恢复勾选的文件/目录到原位置,满足「只找回某个误删文件」
这一最常见的恢复诉求,无需整体覆盖恢复。
- backup:TaskSpec.SelectedPaths;FileRunner.Restore 按选中集合过滤提取,
选中目录即恢复其子项;差异链中删除项亦仅在选中范围内应用(避免误删未选中文件)
路径仅作为成员判断,不参与文件路径构造,无路径穿越面
- restore:RestoreService.StartSelective(Start 委托其 nil 入参,零破坏既有调用);
校验按需恢复仅限本机文件备份;选中路径透传至 spec
- http:POST /backup/records/:id/restore 可选 body { selectedPaths }
- 前端:内容浏览弹窗支持勾选与「恢复选中」,触发按需恢复并跳转恢复日志
测试:pathSelected 边界、按需恢复端到端(仅选中项还原、未选中不出现);
go test 全绿;tsc --noEmit 通过。
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.
背景
此前恢复是「全有或全无」——要么整体覆盖恢复,要么不恢复。但最常见的恢复诉求其实是「只把误删的那一个文件/目录找回来」。本 PR 在上一个「内容浏览」能力之上,补齐按需(选择性)恢复,形成完整的「浏览 → 勾选 → 恢复」恢复闭环。
实现
backup:TaskSpec.SelectedPaths;FileRunner.Restore按选中集合过滤——仅提取选中的文件,选中目录则恢复其全部子项;差异链中的删除项也仅在选中范围内应用,避免误删未选中文件。pathSelected)与前端筛选,从不参与文件写入路径的构造(写入路径仍来自归档条目名),因此无路径穿越/注入面——区别于请求传入目标路径的 feat(restore): 恢复到指定目录(文件类型本机恢复 + 确认弹窗输入) #86。restore:新增RestoreService.StartSelective,原Start委托其nil入参(零破坏既有调用);校验按需恢复仅限本机文件备份;选中路径透传至 spec,对恢复链(全量+差异)逐段一致过滤。http:POST /backup/records/:id/restore接受可选 body{ selectedPaths }。测试
pathSelected边界(精确匹配/目录子项/前缀相近不误判)go test ./...全绿;tsc --noEmit通过范围