fixup-features: Use write-and-rename pattern.

This commit is contained in:
Nick Mathewson 2023-03-20 13:29:27 -04:00
parent cd4895e525
commit 61096d61c3
1 changed files with 3 additions and 1 deletions

View File

@ -269,7 +269,9 @@ impl Crate {
let new_text = self.toml_doc.to_string();
if new_text != old_text {
println!("{} changed. Replacing.", self.name);
std::fs::write(&self.toml_file, new_text.as_str())?;
let tmpname = self.toml_file.with_extension("toml.tmp");
std::fs::write(&tmpname, new_text.as_str())?;
std::fs::rename(&tmpname, &self.toml_file)?;
}
Ok(())
}