Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try harder to create rules backup #967

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
try harder to back up temp file
jw3 committed Dec 19, 2023
commit 5c513afb634d482468aef696c7e94ddd0354acb0
7 changes: 6 additions & 1 deletion crates/daemon/src/profiler.rs
Original file line number Diff line number Diff line change
@@ -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());