From 4c1dca73c4e7d8bd42718805e697c56dfeb2f9ed Mon Sep 17 00:00:00 2001 From: wafflecoffee Date: Fri, 2 Sep 2022 15:19:39 -0400 Subject: [PATCH] Replace remaining icon.ext image paths with hash (#435) Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com> --- src/routes/project_creation.rs | 3 ++- src/routes/users.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/project_creation.rs b/src/routes/project_creation.rs index 6e97f6b12..afcfd2721 100644 --- a/src/routes/project_creation.rs +++ b/src/routes/project_creation.rs @@ -907,10 +907,11 @@ async fn process_icon_upload( ) .await?; + let hash = sha1::Sha1::from(&data).hexdigest(); let upload_data = file_host .upload_file( content_type, - &format!("data/{}/icon.{}", project_id, file_extension), + &format!("data/{}/{}.{}", project_id, hash, file_extension), data.freeze(), ) .await?; diff --git a/src/routes/users.rs b/src/routes/users.rs index 5501e2455..710b16ca8 100644 --- a/src/routes/users.rs +++ b/src/routes/users.rs @@ -354,10 +354,11 @@ pub async fn user_icon_edit( ) .await?; + let hash = sha1::Sha1::from(&bytes).hexdigest(); let upload_data = file_host .upload_file( content_type, - &format!("user/{}/icon.{}", user_id, ext.ext), + &format!("user/{}/{}.{}", user_id, hash, ext.ext), bytes.freeze(), ) .await?;