From 2070381e8131b899b34abaff8bac2ac225686fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20Karsl=C4=B1?= <17887754+ismailkarsli@users.noreply.github.com> Date: Fri, 17 Nov 2023 12:01:32 +0300 Subject: [PATCH] Add upload_timeout to PictrsConfig (#4159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add upload timeout to PictrsConfig * Bad space 🤔 * Update PictrsConfig upload timeout to include units. --- config/defaults.hjson | 2 ++ crates/routes/src/images.rs | 2 +- crates/utils/src/settings/structs.rs | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/defaults.hjson b/config/defaults.hjson index 04e34f978..880af802c 100644 --- a/config/defaults.hjson +++ b/config/defaults.hjson @@ -52,6 +52,8 @@ # hotlinking is allowed. If that is the case for your instance, make sure that this setting is # disabled. cache_external_link_previews: true + # Timeout for uploading images to pictrs (in seconds) + upload_timeout: 30 } # Email sending configuration. All options except login/password are mandatory email: { diff --git a/crates/routes/src/images.rs b/crates/routes/src/images.rs index a537300d2..6b5d9d958 100644 --- a/crates/routes/src/images.rs +++ b/crates/routes/src/images.rs @@ -107,7 +107,7 @@ async fn upload( client_req = client_req.header("X-Forwarded-For", addr.to_string()) }; let res = client_req - .timeout(Duration::from_secs(30)) + .timeout(Duration::from_secs(pictrs_config.upload_timeout)) .body(Body::wrap_stream(make_send(body))) .send() .await diff --git a/crates/utils/src/settings/structs.rs b/crates/utils/src/settings/structs.rs index 3664417be..886cd71b6 100644 --- a/crates/utils/src/settings/structs.rs +++ b/crates/utils/src/settings/structs.rs @@ -89,6 +89,10 @@ pub struct PictrsConfig { /// disabled. #[default(true)] pub cache_external_link_previews: bool, + + /// Timeout for uploading images to pictrs (in seconds) + #[default(30)] + pub upload_timeout: u64, } #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]