From e848d9ace55ae35b01f5f4a6ac8aa4d38c9cf763 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Thu, 29 May 2025 17:42:54 -0500 Subject: [PATCH] Delete old do_upload_release --- src/main.rs | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/src/main.rs b/src/main.rs index a44e2c7..09d2c89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,56 +88,3 @@ async fn main() -> Result<(), gt_tools::Error> { fn reqwest_to_gttool(err: reqwest::Error) -> gt_tools::Error { gt_tools::Error::WrappedReqwestErr(err) } - -async fn do_upload_release( - client: &reqwest::Client, - gitea_url: &str, - repo: &str, - release_id: usize, - files: Vec, -) -> Result<(), Error> { - let token = env::var("RELEASE_KEY_GITEA").expect( - "You must set the RELEASE_KEY_GITEA environment variable so the Gitea API can be used.", - ); - let request_url = format!( - "{gitea_url}{front}{repo}{back}/{id}/assets", - front = API_RELEASE_FRONT, - back = API_RELEASE_BACK, - id = release_id - ); - // Setup a "partial request". I'll need to loop over the files, so I'll - // clone this a bunch of times for each one - let partial_request = client - .post(request_url) - .header(USER_AGENT, "gt-tools-test-agent") - .header(ACCEPT, "application/json") - .header("Authorization", format!("token {}", token)); - - // Ensure all files exists before starting the uploads - for file in &files { - assert!(fs::exists(file) - .expect(&format!("Can't check existence of {file}")) - ); - } - - for file in files { - if let Some(request) = partial_request.try_clone() { - println!("Uploading file {}", &file); - let data = reqwest::multipart::Part::stream(fs::read(&file).unwrap()) - .file_name("attachment") - .mime_str("text/plain")?; - - let form= reqwest::multipart::Form::new() - .part("attachment", data); - - let request = request - .multipart(form) - .query(&[("name", file.split("/").last())]) - .send() - .await?; - } else { - panic!("Failed to clone the RequestBuilder during file upload loop."); - } - } - Ok(()) -}