diff --git a/src/main.rs b/src/main.rs index 02bd869..650be33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +use std::fs; + use gt_tool::cli::Args; use gt_tool::structs::release::{CreateReleaseOption, Release}; @@ -78,14 +80,26 @@ async fn main() -> Result<(), gt_tool::Error> { gt_tool::api::release::list_releases(&client, &args.gitea_url, &args.repo).await?; if let Some(release) = match_release_by_tag(&tag_name, release_candidates) { - gt_tool::api::release_attachment::create_release_attachment( - &client, - &args.gitea_url, - &args.repo, - release.id, - files, - ) - .await?; + for file in &files { + match fs::exists(file) { + Ok(true) => continue, + Ok(false) => return Err(gt_tool::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)"); + }, + } + } + for file in files { + let _attach_desc = gt_tool::api::release_attachment::create_release_attachment( + &client, + &args.gitea_url, + &args.repo, + release.id, + file, + ) + .await?; + } } else { println!("ERR: Couldn't find a release matching the tag \"{tag_name}\"."); return Err(gt_tool::Error::NoSuchRelease);