Clean up temp repos when manage reset or finish-reset fails
还没有人认领这个 Issue。
评估
调研方向
Start with the reset and FinishReset handlers in the manage API, along with GetTempRepoPath, InitRepoAt, SoftDeleteRepo, CleanupRepoFolder and DeleteRepoIfExists, which the issue names. Check whether the repo exists before InitRepoAt runs in reset, and wrap the temp-directory work in FinishReset so a failure deletes _____temp_____/{code}__upload__{ts}. Done means both failure paths leave no temp directory behind and the 404 and error responses are unchanged.
由索引模型根据 Issue 内容生成。
描述
Two manage operations leave a directory behind in _____temp_____ when they fail partway through.
1. POST /api/manage/repos/{code}/reset on a repo that doesn't exist
var tmpRepo = new DirectoryInfo(GetTempRepoPath(code, "reset"));
await InitRepoAt(tmpRepo, cancellationToken); // creates _____temp_____/{code}__reset__{ts}
await SoftDeleteRepo(code, ResetSoftDeleteSuffix(...)); // throws DirectoryNotFoundException -> 404
tmpRepo.MoveTo(PrefixRepoFilePath(code)); // never reached
The caller gets a 404, but the freshly initialised temp repo is never cleaned up.
2. POST /api/manage/repos/{code}/finish-reset with a corrupt or invalid zip
FinishReset creates _____temp_____/{code}__upload__{ts} and then extracts into it. If ExtractToDirectory throws (bad zip, InvalidDataException, IO error, cancellation), the partially extracted directory stays behind. Only the "no .hg folder" path deletes it. The same is true for exceptions thrown later in the method, for example from CleanupRepoFolder or DeleteRepoIfExists.
Nothing cleans up _____temp_____, so these accumulate on the volume (a failed upload can be large).
Suggested fix: wrap both in try/catch (or finally with a success flag) that deletes the temp directory on failure. For reset, check that the repo exists before running InitRepoAt.
Note: this logic is a port of LexBox's HgService, which has the same behaviour today, so LexBox will keep this behaviour when it switches to /api/manage unless it's fixed here.
- 主要语言
- C#
- 星标
- 0
- 派生
- 1
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sillsdev/hgresume 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 3/5 半天 新手友好度 45/100
-
难度 1/5 1 小时以内 新手友好度 50/100
-
难度 5/5 一周以上 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
查看 sillsdev/hgresume 的全部 Issue
相似的 Issue
-
bug 優先: 低
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
-
.NET area: storage bug good first issue
难度 2/5 1-3 小时 新手友好度 78/100
Larson-Logan/medal-sync#61 ·
维护者通常 1 天内回复
-
area-ai bug untriaged
难度 2/5 1-3 小时 新手友好度 67/100
dotnet/extensions#7893 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100