Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions server/src/handlers/http/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<serde_json::Value> {
let meta = StorageMetadata::global();
Expand Down Expand Up @@ -48,6 +50,21 @@ pub async fn about() -> Json<serde_json::Value> {
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<PathBuf> = CONFIG.cache_dir();
let cache_size: SpecificSize<human_size::Gigibyte> =
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,
Expand All @@ -61,6 +78,7 @@ pub async fn about() -> Json<serde_json::Value> {
"license": "AGPL-3.0-only",
"mode": mode,
"staging": staging,
"cache": cache_details,
"grpcPort": grpc_port,
"store": store
}))
Expand Down
8 changes: 8 additions & 0 deletions server/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf> {
&self.parseable.local_cache_path
}

pub fn is_default_creds(&self) -> bool {
self.parseable.username == Server::DEFAULT_USERNAME
&& self.parseable.password == Server::DEFAULT_PASSWORD
Expand Down