Skip to content

Commit

Permalink
Merge pull request #261 from nyx-space/hotfix/deleting-lock
Browse files Browse the repository at this point in the history
Deletion of lock file should not fail if lock not found
  • Loading branch information
ChristopherRabotin committed Jun 9, 2024
2 parents 32c83c1 + f46549c commit 9561d88
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions anise/src/almanac/metaload/metafile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,9 @@ impl MetaFile {
});
}

let del_lock_file = || -> Result<(), MetaAlmanacError> {
if let Err(e) = remove_file(lock_path) {
return Err(MetaAlmanacError::MetaIO {
path: dest_path
.join(".lock")
.to_str()
.unwrap()
.into(),
what: "deleting lock file",
source: InputOutputError::IOError {
kind: e.kind(),
},
});
}
Ok(())
let del_lock_file = || {
// Ignore if the deletion of the lock file fails
let _ = remove_file(lock_path);
};

let client = reqwest::blocking::Client::builder()
Expand All @@ -179,7 +167,7 @@ impl MetaFile {
// Downloaded the file, let's store it locally.
match File::create(&dest_path) {
Err(e) => {
del_lock_file()?;
del_lock_file();
Err(MetaAlmanacError::MetaIO {
path: dest_path
.to_str()
Expand Down Expand Up @@ -211,21 +199,21 @@ impl MetaFile {
// Set the CRC32
self.crc32 = Some(crc32);

del_lock_file()?;
del_lock_file();

Ok(())
}
}
} else {
del_lock_file()?;
del_lock_file();
Err(MetaAlmanacError::FetchError {
status: resp.status(),
uri: self.uri.clone(),
})
}
}
Err(e) => {
del_lock_file()?;
del_lock_file();
Err(MetaAlmanacError::CnxError {
uri: self.uri.clone(),
error: format!("{e}"),
Expand Down

0 comments on commit 9561d88

Please sign in to comment.