Repository navigation
fix(minimax-bot): 定时任务删除写盘失败时恢复原状态 - #189
Open
Apageoflove wants to merge 1 commit into
Open
Apageoflove wants to merge 1 commit into
Apageoflove wants to merge 1 commit into
Conversation
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.
删除定时任务时,代码先把任务从内存里移除,再写盘。写盘失败,调用方收到的是“删除失败”,但内存里已经没有它了;下一次无关的保存就会把这个不存在写进磁盘,任务从此消失。
用真实文件系统失败复现:把
state.json临时移走,在原路径建目录,让最后一次 rename 报EISDIR。结果是:用户看到删除失败,任务却已经没了。
改的是
deleteSchedule():写盘失败时,只把它删掉的那一条定时任务放回当前列表。没有恢复整个旧数组,所以写盘等待期间另一个调用做的改动不会被一起撤销。成功后路径不变,仍然删除、写盘、通知页面。测试加了两条:一条用真实
EISDIR断言失败后内存和磁盘都还留着任务,后续保存和重启也还在;另一条让写在保存期间失败,同时往列表里加另一条任务,断言失败删除被回滚、但那条并发改动保留。两条在未改的 main 上都是红的。全量 442 条串行通过。版本号 0.7.45。当前 main 是 0.7.40;前面还有 #184(0.7.41)、#172(0.7.42)、#187(0.7.43)、#188(0.7.44),按这个顺序合。
验证范围:只有 Node 22 上的测试是实测的。真实 Host 和 Electron 我没跑过 —— 这一层是仅个人判断。
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.