Skip to content

Commit

Permalink
try harder to back up temp file
Browse files Browse the repository at this point in the history
  • Loading branch information
jw3 committed Dec 19, 2023
1 parent c0cce6f commit 5c513af
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/daemon/src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ impl Profiler {
// create a temp file as the backup location
let backup = NamedTempFile::new()?;
// move original compiled to backup location
fs::rename(&compiled, &backup)?;
fs::rename(&compiled, &backup).or_else(|x| {
log::debug!("rename fallback copy");
fs::copy(&compiled, &backup)
.and_then(|_| fs::remove_file(&compiled))
.or(Err(x))
})?;
// write compiled rules for the profiling run
write::compiled_rules(db, &compiled)?;
log::debug!("rules backed up to {:?}", backup.path());
Expand Down

0 comments on commit 5c513af

Please sign in to comment.