server: remove jobstate: ignore removal error due to file not found
we want to remove lock and state file anyway, so not found is all right Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
14433718fb
commit
ceb815d295
@ -112,24 +112,17 @@ where
|
||||
pub fn remove_state_file(jobtype: &str, jobname: &str) -> Result<(), Error> {
|
||||
let mut path = get_path(jobtype, jobname);
|
||||
let _lock = get_lock(&path)?;
|
||||
std::fs::remove_file(&path).map_err(|err| {
|
||||
format_err!(
|
||||
"cannot remove statefile for {} - {}: {}",
|
||||
jobtype,
|
||||
jobname,
|
||||
err
|
||||
)
|
||||
})?;
|
||||
if let Err(err) = std::fs::remove_file(&path) {
|
||||
if err.kind() != std::io::ErrorKind::NotFound {
|
||||
bail!("cannot remove statefile for {jobtype} - {jobname}: {err}");
|
||||
}
|
||||
}
|
||||
path.set_extension("lck");
|
||||
// ignore errors
|
||||
let _ = std::fs::remove_file(&path).map_err(|err| {
|
||||
format_err!(
|
||||
"cannot remove lockfile for {} - {}: {}",
|
||||
jobtype,
|
||||
jobname,
|
||||
err
|
||||
)
|
||||
});
|
||||
if let Err(err) = std::fs::remove_file(&path) {
|
||||
if err.kind() != std::io::ErrorKind::NotFound {
|
||||
bail!("cannot remove lockfile for {jobtype} - {jobname}: {err}");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user