Skip to content

Commit eab6fc3

Browse files
haasonsaasclaude
andcommitted
Clean up temp files on failed atomic rename in state persistence
Prevents leftover .json.tmp files containing potentially sensitive review/config data when rename fails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 273232f commit eab6fc3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/server/state.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl AppState {
104104
}
105105
if let Err(e) = tokio::fs::rename(&tmp_path, &state.storage_path).await {
106106
eprintln!("Failed to rename reviews file: {}", e);
107+
let _ = tokio::fs::remove_file(&tmp_path).await;
107108
}
108109
});
109110
}
@@ -136,6 +137,7 @@ impl AppState {
136137
}
137138
if let Err(e) = tokio::fs::rename(&tmp_path, &state.config_path).await {
138139
eprintln!("Failed to rename config file: {}", e);
140+
let _ = tokio::fs::remove_file(&tmp_path).await;
139141
}
140142
});
141143
}

0 commit comments

Comments
 (0)