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 148bb1a
Show file tree
Hide file tree
Showing 2 changed files with 10 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
4 changes: 4 additions & 0 deletions crates/tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ license = "GPL-3.0-or-later"
version = "0.5.0"
edition = "2021"

[[bin]]
name = "rr"
path = "src/rule_reloader.rs"

[[bin]]
name = "tdb"
path = "src/trust_db_util.rs"
Expand Down

0 comments on commit 148bb1a

Please sign in to comment.