feat(instance): 删除实例前备份截图与投影原理图 [GPT-5.6] - #3537
Conversation
Reviewer's Guide在删除隔离实例时新增可配置的个人文件备份流程,包括新的备份模式设置、UI 提示,以及用于截图和示意图的递归复制工具;当备份失败时会中止删除操作。 在删除隔离实例期间进行个人文件备份的时序图sequenceDiagram
actor User
participant PageSelectRight
participant ModPersonalFiles
participant ModMain
participant FileSystem
User->>PageSelectRight: DeleteVersion(mcInstance)
PageSelectRight->>ModPersonalFiles: GetDeleteHint()
PageSelectRight->>ModMain: MyMsgBox(confirmFullMsg)
ModMain-->>PageSelectRight: confirmResult = 1
PageSelectRight->>ModPersonalFiles: TryHandleBeforeDelete(mcInstance)
alt PersonalFilesBackupMode.Disabled
ModPersonalFiles-->>PageSelectRight: return true
else PersonalFilesBackupMode.AskEveryTime
ModPersonalFiles->>ModPersonalFiles: _HasScreenshots(mcInstance.PathIndie)
alt [no screenshots]
ModPersonalFiles-->>PageSelectRight: return true
else [screenshots exist]
ModPersonalFiles->>ModMain: MyMsgBox(Ask.Message, Ask.Title)
ModMain-->>ModPersonalFiles: promptResult
alt promptResult == 2 (DeleteWithoutBackup)
ModPersonalFiles-->>PageSelectRight: return true
else promptResult != 1 (Cancel)
ModPersonalFiles-->>PageSelectRight: return false
else promptResult == 1 (BackupAndDelete)
ModPersonalFiles->>ModPersonalFiles: _Backup(mcInstance)
ModPersonalFiles->>FileSystem: Copy screenshots & schematics
ModPersonalFiles->>HintService: Hint(Backup.Success)
ModPersonalFiles-->>PageSelectRight: return true
end
end
else PersonalFilesBackupMode.Always
ModPersonalFiles->>ModPersonalFiles: _Backup(mcInstance)
ModPersonalFiles->>FileSystem: Copy screenshots & schematics
ModPersonalFiles->>HintService: Hint(Backup.Success)
ModPersonalFiles-->>PageSelectRight: return true
end
PageSelectRight->>ModBase: IniClearCache(options.txt)
PageSelectRight->>ConfigService: InvalidateCache(mcInstance.PathInstance)
PageSelectRight->>FileSystem: Delete instance files
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your Experience访问你的 dashboard 以:
Getting HelpOriginal review guide in EnglishReviewer's GuideAdds a configurable personal-files backup workflow when deleting isolated instances, including a new backup mode setting, UI hints, and a recursive copy utility for screenshots and schematics that aborts deletion on backup failure. Sequence diagram for personal files backup during isolated instance deletionsequenceDiagram
actor User
participant PageSelectRight
participant ModPersonalFiles
participant ModMain
participant FileSystem
User->>PageSelectRight: DeleteVersion(mcInstance)
PageSelectRight->>ModPersonalFiles: GetDeleteHint()
PageSelectRight->>ModMain: MyMsgBox(confirmFullMsg)
ModMain-->>PageSelectRight: confirmResult = 1
PageSelectRight->>ModPersonalFiles: TryHandleBeforeDelete(mcInstance)
alt PersonalFilesBackupMode.Disabled
ModPersonalFiles-->>PageSelectRight: return true
else PersonalFilesBackupMode.AskEveryTime
ModPersonalFiles->>ModPersonalFiles: _HasScreenshots(mcInstance.PathIndie)
alt [no screenshots]
ModPersonalFiles-->>PageSelectRight: return true
else [screenshots exist]
ModPersonalFiles->>ModMain: MyMsgBox(Ask.Message, Ask.Title)
ModMain-->>ModPersonalFiles: promptResult
alt promptResult == 2 (DeleteWithoutBackup)
ModPersonalFiles-->>PageSelectRight: return true
else promptResult != 1 (Cancel)
ModPersonalFiles-->>PageSelectRight: return false
else promptResult == 1 (BackupAndDelete)
ModPersonalFiles->>ModPersonalFiles: _Backup(mcInstance)
ModPersonalFiles->>FileSystem: Copy screenshots & schematics
ModPersonalFiles->>HintService: Hint(Backup.Success)
ModPersonalFiles-->>PageSelectRight: return true
end
end
else PersonalFilesBackupMode.Always
ModPersonalFiles->>ModPersonalFiles: _Backup(mcInstance)
ModPersonalFiles->>FileSystem: Copy screenshots & schematics
ModPersonalFiles->>HintService: Hint(Backup.Success)
ModPersonalFiles-->>PageSelectRight: return true
end
PageSelectRight->>ModBase: IniClearCache(options.txt)
PageSelectRight->>ConfigService: InvalidateCache(mcInstance.PathInstance)
PageSelectRight->>FileSystem: Delete instance files
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
关于备份截图的想法,得和 @Pigeon0v0 探讨下,删除实例损失了游玩的回忆会很可惜,但仍不确定这个功能,要以何种方式实现,目前的想法是全局设置打开后,删除游戏时会先备份截图。投影原理图是顺带的。 |
|
可以加一个每次均询问的选项,如果截图文件夹里有东西就弹个窗问一下 |
There was a problem hiding this comment.
Hey - 我在这里给出了一些总体反馈:
- 请考虑在
ModPersonalFiles._ArchiveRoot中针对ModFolder.mcFolderSelected为空或未设置的情况进行保护,这样在未选择游戏根目录时触发的删除流程就不会抛出异常或生成无效的备份路径。 - 在
_CopyDirectory中,确保在调用ModBase.CopyFile之前先创建目标子目录(例如通过Directory.CreateDirectory(Path.GetDirectoryName(targetFile))),这样无论CopyFile的具体行为如何,嵌套的screenshots/schematics文件都能被可靠地复制。
供 AI 代理使用的提示
Please address the comments from this code review:
## Overall Comments
- Consider guarding `ModPersonalFiles._ArchiveRoot` against a null or unset `ModFolder.mcFolderSelected` so that delete flows invoked when no game root is selected don’t throw or produce an invalid backup path.
- In `_CopyDirectory`, ensure the target subdirectories are created (e.g. via `Directory.CreateDirectory(Path.GetDirectoryName(targetFile))`) before calling `ModBase.CopyFile` so nested `screenshots/schematics` files are copied reliably regardless of `CopyFile`'s behavior.帮我变得更有用!请对每条评论点击 👍 或 👎,我会根据这些反馈改进为你提供的代码审查。
Original comment in English
Hey - I've left some high level feedback:
- Consider guarding
ModPersonalFiles._ArchiveRootagainst a null or unsetModFolder.mcFolderSelectedso that delete flows invoked when no game root is selected don’t throw or produce an invalid backup path. - In
_CopyDirectory, ensure the target subdirectories are created (e.g. viaDirectory.CreateDirectory(Path.GetDirectoryName(targetFile))) before callingModBase.CopyFileso nestedscreenshots/schematicsfiles are copied reliably regardless ofCopyFile's behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider guarding `ModPersonalFiles._ArchiveRoot` against a null or unset `ModFolder.mcFolderSelected` so that delete flows invoked when no game root is selected don’t throw or produce an invalid backup path.
- In `_CopyDirectory`, ensure the target subdirectories are created (e.g. via `Directory.CreateDirectory(Path.GetDirectoryName(targetFile))`) before calling `ModBase.CopyFile` so nested `screenshots/schematics` files are copied reliably regardless of `CopyFile`'s behavior.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec82020b51
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { | ||
| case 1: | ||
| { | ||
| if (isHintIndie && !ModPersonalFiles.TryHandleBeforeDelete(mcInstance)) return; |
There was a problem hiding this comment.
Back up isolated instances even when validation fails
When an isolated instance has a corrupt or unreadable version definition, its state is McInstanceState.Error, which forces isHintIndie to false and skips this new backup handler even if PathIndie is the instance directory. The delete operation still removes PathInstance, so screenshots and schematics are silently lost under both Ask and Always modes; determine isolation from the configured/path relationship or probe the instance directory independently of validation state.
Useful? React with 👍 / 👎.
This comment was marked as spam.
This comment was marked as spam.
|
Request |
修改内容
screenshots中存在文件时弹窗,可选择备份并删除、直接删除或取消screenshots与schematics递归复制到所选游戏目录下的PCL/PersonalFiles/<实例名>验证情况
dotnet build "Plain Craft Launcher 2/Plain Craft Launcher 2.csproj" -c Debug -p:Platform=x64 --no-restore:通过,0 个错误CI配置dotnet publish --no-self-contained:通过;生成的 .NET 10 可执行文件启动冒烟通过git diff --check dev...feat/protect-instance-personal-files:通过AI 使用
Summary by Sourcery
在删除隔离的 Minecraft 实例时,新增可配置的个人文件保护机制,包括可选地将截图和结构文件备份到专用归档文件夹。
New Features:
Enhancements:
Original summary in English
Summary by Sourcery
Add configurable protection for personal files when deleting isolated Minecraft instances, including optional backup of screenshots and schematics to a dedicated archive folder.
New Features:
Enhancements: