Skip to content

Commit

Permalink
Merge pull request #3 from flub/cleanup-notfound
Browse files Browse the repository at this point in the history
On cleanup treat notfound as ok
  • Loading branch information
flub authored Oct 4, 2023
2 parents 8e43e97 + f2a57b5 commit 77c73b1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/numbered_dir.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! The [`NumberedDir`] type and supporting code.
use std::io::ErrorKind;
use std::num::NonZeroU8;
use std::path::{Path, PathBuf};
use std::{fs, io};
Expand Down Expand Up @@ -137,8 +138,14 @@ fn remove_obsolete_dirs(dir: impl AsRef<Path>, base: &str, current: u16, keep: u
|| (oldest_to_keep < oldest_to_delete
&& (numdir.number < oldest_to_keep || numdir.number >= oldest_to_delete))
{
fs::remove_dir_all(numdir.path())
.with_context(|| format!("Failed to remove {}", numdir.path().display()))?;
match fs::remove_dir_all(numdir.path()) {
Ok(_) => (),
Err(err) if err.kind() == ErrorKind::NotFound => (),
Err(err) => {
return Err(err)
.with_context(|| format!("Failed to remove {}", numdir.path().display()))
}
}
}
}

Expand Down

0 comments on commit 77c73b1

Please sign in to comment.