fix(chess-skin-admin): cascade file cleanup on delete and replace - #27
Merged
Conversation
deleteSkin 之前只移 KV index,文件资源保留 —— 与"删除"语义不一致,且长期累积 孤儿文件。现改为文件先删 + KV 后移:并发 DELETE 全部 pieces 与 boardBackground, 任一失败抛错中止(KV 不动);全部成功才移除 KV index。 replacePiece 同样会在 KV 持久化后 best-effort 清理被替换的旧 fileId(失败仅记 录,不影响主操作),避免每次换皮都留下一个孤儿文件。 UI 文案同步更新:删除 modal 描述移除"文件资源保留",按钮 tooltip 改为"联动删 除文件";替换 status 在新旧文件清状态之间给出三种文案分支。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Sep 4, 2026
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.
背景
chess-skin-admin的两个清理路径都漏删文件:deleteSkin: 只移 KV index,文件资源保留 —— 与"删除"语义不一致,且长期累积孤儿文件replacePiece: 每次换皮都上传新图 + 改 KV,但旧文件从不清理,storage 持续增长改动
deleteSkin(composable)改为文件先删,KV 后移;任一失败中止(KV 不动):
Promise.allSettled调用fileV1Service.delete({fileId, groupId:190})error.value并抛错;KV index 一字不动boardBackground类型是unknown,仅在长得像{fileId:string}时尝试删,避免误删。返回类型从
Promise<void>变为Promise<DeleteSkinResult>(pieceFilesDeleted,backgroundDeleted),供 UI 显示文件清理计数。replacePiece(composable)新增 best-effort 清理被替换的旧 fileId:
fileIdDELETE旧 fileId,失败只挂orphanedFailed,不影响主操作设计取舍:
返回类型从
Promise<ChessSkinMeta>变为Promise<ReplacePieceResult>(meta,orphanedCleaned,orphanedFailed)。UI 文案更新
验证
lint-staged通过(ESLint 0 warnings)pnpm lint+pnpm --filter @style-library/showcase build兜底验证(本机 Node 16 未跑)已知遗留
本轮改动只清未来新增的孤儿。已有的历史孤儿(改动前留下的旧 fileId 引用)未清理。可加一个
cleanOrphans()工具函数遍历index.value然后用fileV1Service.list按 tag 反查并删除,但属于独立功能,留作下一轮。🤖 Generated with Claude Code