diff --git a/server/src/handlers/http/about.rs b/server/src/handlers/http/about.rs index dce3bf3c8..2c8db6b9a 100644 --- a/server/src/handlers/http/about.rs +++ b/server/src/handlers/http/about.rs @@ -17,9 +17,11 @@ */ use actix_web::web::Json; +use human_size::SpecificSize; use serde_json::json; use crate::{about, option::CONFIG, storage::StorageMetadata, utils::update}; +use std::path::PathBuf; pub async fn about() -> Json { let meta = StorageMetadata::global(); @@ -48,6 +50,21 @@ pub async fn about() -> Json { let is_oidc_active = CONFIG.parseable.openid.is_some(); let ui_version = option_env!("UI_VERSION").unwrap_or("development"); + let cache_details: String = if CONFIG.cache_dir().is_none() { + "Disabled".to_string() + } else { + let cache_dir: &Option = CONFIG.cache_dir(); + let cache_size: SpecificSize = + SpecificSize::new(CONFIG.cache_size() as f64, human_size::Byte) + .unwrap() + .into(); + format!( + "Enabled, Path: {} (Size: {})", + cache_dir.as_ref().unwrap().display(), + cache_size + ) + }; + Json(json!({ "version": current_version, "uiVersion": ui_version, @@ -61,6 +78,7 @@ pub async fn about() -> Json { "license": "AGPL-3.0-only", "mode": mode, "staging": staging, + "cache": cache_details, "grpcPort": grpc_port, "store": store })) diff --git a/server/src/option.rs b/server/src/option.rs index f20069305..68fea5db2 100644 --- a/server/src/option.rs +++ b/server/src/option.rs @@ -112,6 +112,14 @@ impl Config { &self.parseable.local_staging_path } + pub fn cache_size(&self) -> u64 { + self.parseable.local_cache_size + } + + pub fn cache_dir(&self) -> &Option { + &self.parseable.local_cache_path + } + pub fn is_default_creds(&self) -> bool { self.parseable.username == Server::DEFAULT_USERNAME && self.parseable.password == Server::DEFAULT_PASSWORD