fix: keep task completion, cancel, pause, and undo honest
Pending earlier-revision jobs no longer skip completion repair; late cancels preserve real exits; begin clears pause; partial undo keeps snapshots; permissions and worktree failure paths are hardened. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+10
-1
@@ -83,12 +83,21 @@ static int save(const cst_perms_t *p) {
|
||||
cJSON_Delete(root);
|
||||
if (!txt)
|
||||
return -1;
|
||||
FILE *fp = fopen(p->path, "wb");
|
||||
char tmp[OS_PATH_MAX + 8];
|
||||
if (snprintf(tmp, sizeof(tmp), "%s.tmp", p->path) >= (int)sizeof(tmp)) {
|
||||
free(txt);
|
||||
return -1;
|
||||
}
|
||||
FILE *fp = fopen(tmp, "wb");
|
||||
int rc = -1;
|
||||
if (fp) {
|
||||
rc = fputs(txt, fp) >= 0 && fputs("\n", fp) >= 0 ? 0 : -1;
|
||||
if (fclose(fp) != 0)
|
||||
rc = -1;
|
||||
if (rc == 0)
|
||||
rc = os_rename_replace(tmp, p->path);
|
||||
if (rc != 0)
|
||||
remove(tmp);
|
||||
}
|
||||
free(txt);
|
||||
return rc;
|
||||
|
||||
Reference in New Issue
Block a user