We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 77c098b commit 922af60Copy full SHA for 922af60
1 file changed
bin/ev-deployer/src/deploy/state.rs
@@ -86,10 +86,12 @@ impl DeployState {
86
Ok(state)
87
}
88
89
- /// Save state to a JSON file.
+ /// Save state to a JSON file atomically (write to tmp, then rename).
90
pub(crate) fn save(&self, path: &Path) -> eyre::Result<()> {
91
let json = serde_json::to_string_pretty(self)?;
92
- std::fs::write(path, json)?;
+ let tmp = path.with_extension("tmp");
93
+ std::fs::write(&tmp, &json)?;
94
+ std::fs::rename(&tmp, path)?;
95
Ok(())
96
97
0 commit comments