From cb9a594f24ea7ed34faf716b0b06a5bab13d949e Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 21 Jun 2022 11:27:22 -0500 Subject: [PATCH] Fix content type on already processed images --- src/main.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a34ffeb..f8b6471 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,6 +47,8 @@ mod stream; mod tmp_file; mod validate; +use crate::magick::ValidInputType; + use self::{ backgrounded::Backgrounded, config::{Configuration, ImageFormat, Operation}, @@ -419,7 +421,24 @@ async fn process( .await?; if let Some(identifier) = identifier_opt { - let details = ensure_details(&**repo, &**store, &alias).await?; + let details = repo.details(&identifier).await?; + + let details = if let Some(details) = details { + debug!("details exist"); + details + } else { + debug!("generating new details from {:?}", identifier); + let new_details = Details::from_store( + (**store).clone(), + identifier.clone(), + Some(ValidInputType::from_format(format)), + ) + .await?; + debug!("storing details for {:?}", identifier); + repo.relate_details(&identifier, &new_details).await?; + debug!("stored"); + new_details + }; return ranged_file_resp(&**store, identifier, range, details).await; }