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> {
|
pub fn remove_state_file(jobtype: &str, jobname: &str) -> Result<(), Error> {
|
||||||
let mut path = get_path(jobtype, jobname);
|
let mut path = get_path(jobtype, jobname);
|
||||||
let _lock = get_lock(&path)?;
|
let _lock = get_lock(&path)?;
|
||||||
std::fs::remove_file(&path).map_err(|err| {
|
if let Err(err) = std::fs::remove_file(&path) {
|
||||||
format_err!(
|
if err.kind() != std::io::ErrorKind::NotFound {
|
||||||
"cannot remove statefile for {} - {}: {}",
|
bail!("cannot remove statefile for {jobtype} - {jobname}: {err}");
|
||||||
jobtype,
|
}
|
||||||
jobname,
|
}
|
||||||
err
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
path.set_extension("lck");
|
path.set_extension("lck");
|
||||||
// ignore errors
|
if let Err(err) = std::fs::remove_file(&path) {
|
||||||
let _ = std::fs::remove_file(&path).map_err(|err| {
|
if err.kind() != std::io::ErrorKind::NotFound {
|
||||||
format_err!(
|
bail!("cannot remove lockfile for {jobtype} - {jobname}: {err}");
|
||||||
"cannot remove lockfile for {} - {}: {}",
|
}
|
||||||
jobtype,
|
}
|
||||||
jobname,
|
|
||||||
err
|
|
||||||
)
|
|
||||||
});
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue