From 1e7cd3b97ab1782e779bd62752b3a03825ca0b3a Mon Sep 17 00:00:00 2001 From: Robert Detjens Date: Sun, 17 Nov 2024 16:26:31 -0800 Subject: [PATCH] Delete asset bucket test file after access checks pass Signed-off-by: Robert Detjens --- src/access_handlers/s3.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/access_handlers/s3.rs b/src/access_handlers/s3.rs index a3bbf90..f1ed323 100644 --- a/src/access_handlers/s3.rs +++ b/src/access_handlers/s3.rs @@ -25,7 +25,12 @@ pub async fn check(profile_name: &str) -> Result<()> { bucket .put_object_with_content_type(test_file.0, test_file.1.as_bytes(), "text/plain") .await - .with_context(|| format!("could not upload to bucket {:?}", profile.s3.bucket_name))?; + .with_context(|| { + format!( + "could not upload to asset bucket {:?}", + profile.s3.bucket_name + ) + })?; // download it to check debug!("downloading test file"); @@ -42,7 +47,7 @@ pub async fn check(profile_name: &str) -> Result<()> { .await .with_context(|| { anyhow!( - "public download from qbucket {:?} failed", + "public download from asset bucket {:?} failed", profile.s3.bucket_name ) })?; @@ -50,6 +55,9 @@ pub async fn check(profile_name: &str) -> Result<()> { bail!("contents of public bucket do not match uploaded file"); } + // clean up test file after checks + bucket.delete_object(test_file.0).await?; + Ok(()) }