Fix the release_attachment file-existence loop
I only dealt with the scenario where I get back an Err(_) value. This is not what happens when the file is missing, it's what happens when there was some other problem interacting with the file. Instead, an Ok(bool) is returned to indicate positive identification of the presence or absence of the file. Something should be done about the std::io::error::Error that gets handed back. Since I'm not expecting to see it very often, nor to really do anything about it, I'm just emitting an error message and panicking.
This commit is contained in:
@@ -16,8 +16,13 @@ pub async fn create_release_attachment(
|
|||||||
|
|
||||||
// Ensure all files exists before starting the uploads
|
// Ensure all files exists before starting the uploads
|
||||||
for file in &files {
|
for file in &files {
|
||||||
if let Err(e) = fs::exists(file) {
|
match fs::exists(file) {
|
||||||
return Err(crate::Error::NoSuchFile);
|
Ok(true) => continue,
|
||||||
|
Ok(false) => return Err(crate::Error::NoSuchFile),
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Uh oh! The file-exists check couldn't be done: {e}");
|
||||||
|
panic!("TODO: Deal with scenario where the file's existence cannot be checked (e.g.: no permission)");
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user