From 2e92ab4bf001f44bc09edc5d22bac7f596196537 Mon Sep 17 00:00:00 2001 From: minish Date: Mon, 27 May 2024 13:12:18 -0400 Subject: [PATCH] max strip len config option --- src/config.rs | 5 +++++ src/engine.rs | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 8532770..13615e3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -37,6 +37,10 @@ pub struct EngineConfig { #[serde_as(as = "DurationSeconds")] pub max_temp_lifetime: Duration, + /// Maximum length (in bytes) a file can be before the server will + /// decide not to remove its EXIF data. + pub max_strip_len: usize, + /// Motd displayed when the server's index page is visited. /// /// This isn't explicitly engine-related but the engine is what gets passed to routes, @@ -73,6 +77,7 @@ pub struct CacheConfig { #[derive(Deserialize)] pub struct HttpConfig { + /// The IP address the HTTP server should listen on pub listen_on: String, } diff --git a/src/engine.rs b/src/engine.rs index d739c75..91b5cef 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -76,7 +76,7 @@ impl Engine { } /// Fetch an upload - /// + /// /// This will first try to read from cache, and then disk after. /// If an upload is eligible to be cached, it will be cached and /// sent back as a cache response instead of a disk response. @@ -160,7 +160,7 @@ impl Engine { } /// Save a file to disk, and optionally cache. - /// + /// /// This also handles custom file lifetimes and EXIF data removal. pub async fn save( &self, @@ -196,7 +196,7 @@ impl Engine { Some(Some("png" | "jpg" | "jpeg" | "webp" | "tiff")) ) && !keep_exif - && provided_len <= 16_777_216; + && provided_len <= self.cfg.max_strip_len; // read and save upload while let Some(chunk) = stream.next().await {