This commit is contained in:
Antoine Gersant 2024-10-13 00:11:33 -07:00
parent cf6a092ab7
commit c640086a3e
6 changed files with 1 additions and 102 deletions

View file

@ -339,61 +339,6 @@
] ]
} }
}, },
"/preferences": {
"get": {
"tags": [
"Users"
],
"summary": "Reads the preferences of the current user",
"operationId": "getPreferences",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#components/schemas/Preferences"
}
}
}
}
},
"security": [
{
"auth_http_bearer": [],
"auth_query_parameter": []
}
]
},
"put": {
"tags": [
"Users"
],
"summary": "Saves the preferences of the current user",
"operationId": "putPreferences",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#components/schemas/Preferences"
}
}
}
},
"responses": {
"200": {
"description": "Successful operation"
}
},
"security": [
{
"auth_http_bearer": [],
"auth_query_parameter": []
}
]
}
},
"/auth": { "/auth": {
"post": { "post": {
"tags": [ "tags": [
@ -967,10 +912,6 @@
"type": "string", "type": "string",
"example": "^Folder.(png|jpg|jpeg)$" "example": "^Folder.(png|jpg|jpeg)$"
}, },
"reindex_every_n_seconds": {
"type": "integer",
"example": 3600
},
"ydns": { "ydns": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -1052,17 +993,6 @@
"name" "name"
] ]
}, },
"Preferences": {
"type": "object",
"properties": {
"web_theme_base": {
"type": "string"
},
"web_theme_accent": {
"type": "string"
}
}
},
"Credentials": { "Credentials": {
"type": "object", "type": "object",
"properties": { "properties": {

View file

@ -23,7 +23,6 @@ use super::auth;
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
pub struct Config { pub struct Config {
pub reindex_every_n_seconds: Option<u64>,
pub album_art_pattern: Option<Regex>, pub album_art_pattern: Option<Regex>,
pub ddns_update_url: Option<http::Uri>, pub ddns_update_url: Option<http::Uri>,
pub mount_dirs: Vec<MountDir>, pub mount_dirs: Vec<MountDir>,
@ -38,8 +37,6 @@ impl TryFrom<storage::Config> for Config {
config.set_mounts(c.mount_dirs)?; config.set_mounts(c.mount_dirs)?;
config.set_users(c.users)?; config.set_users(c.users)?;
config.reindex_every_n_seconds = c.reindex_every_n_seconds;
config.album_art_pattern = match c.album_art_pattern.as_deref().map(Regex::new) { config.album_art_pattern = match c.album_art_pattern.as_deref().map(Regex::new) {
Some(Ok(u)) => Some(u), Some(Ok(u)) => Some(u),
Some(Err(_)) => return Err(Error::IndexAlbumArtPatternInvalid), Some(Err(_)) => return Err(Error::IndexAlbumArtPatternInvalid),
@ -59,7 +56,6 @@ impl TryFrom<storage::Config> for Config {
impl From<Config> for storage::Config { impl From<Config> for storage::Config {
fn from(c: Config) -> Self { fn from(c: Config) -> Self {
Self { Self {
reindex_every_n_seconds: c.reindex_every_n_seconds,
album_art_pattern: c.album_art_pattern.map(|p| p.as_str().to_owned()), album_art_pattern: c.album_art_pattern.map(|p| p.as_str().to_owned()),
mount_dirs: c.mount_dirs.into_iter().map(|d| d.into()).collect(), mount_dirs: c.mount_dirs.into_iter().map(|d| d.into()).collect(),
ddns_update_url: c.ddns_update_url.map(|u| u.to_string()), ddns_update_url: c.ddns_update_url.map(|u| u.to_string()),
@ -176,19 +172,6 @@ impl Manager {
Ok(()) Ok(())
} }
pub async fn get_index_sleep_duration(&self) -> Duration {
let config = self.config.read().await;
let seconds = config.reindex_every_n_seconds.unwrap_or(1800);
Duration::from_secs(seconds)
}
pub async fn set_index_sleep_duration(&self, duration: Duration) -> Result<(), Error> {
self.mutate(|c| {
c.reindex_every_n_seconds = Some(duration.as_secs());
})
.await
}
pub async fn get_index_album_art_pattern(&self) -> Regex { pub async fn get_index_album_art_pattern(&self) -> Regex {
let config = self.config.read().await; let config = self.config.read().await;
let pattern = config.album_art_pattern.clone(); let pattern = config.album_art_pattern.clone();
@ -306,7 +289,6 @@ mod test {
.unwrap(); .unwrap();
let config: storage::Config = manager.config.read().await.clone().into(); let config: storage::Config = manager.config.read().await.clone().into();
assert_eq!(config.reindex_every_n_seconds, None);
assert_eq!( assert_eq!(
config.album_art_pattern, config.album_art_pattern,
Some(r#"^Folder\.(png|jpg|jpeg)$"#.to_owned()) Some(r#"^Folder\.(png|jpg|jpeg)$"#.to_owned())

View file

@ -21,8 +21,6 @@ pub struct MountDir {
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct Config { pub struct Config {
#[serde(skip_serializing_if = "Option::is_none")]
pub reindex_every_n_seconds: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub album_art_pattern: Option<String>, pub album_art_pattern: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")] #[serde(default, skip_serializing_if = "Vec::is_empty")]

View file

@ -1,4 +1,4 @@
use std::{path::PathBuf, time::Duration}; use std::path::PathBuf;
use axum::{ use axum::{
extract::{DefaultBodyLimit, Path, Query, State}, extract::{DefaultBodyLimit, Path, Query, State},
@ -108,7 +108,6 @@ async fn get_settings(
.await .await
.as_str() .as_str()
.to_owned(), .to_owned(),
reindex_every_n_seconds: config_manager.get_index_sleep_duration().await.as_secs(),
ddns_update_url: config_manager ddns_update_url: config_manager
.get_ddns_update_url() .get_ddns_update_url()
.await .await
@ -132,12 +131,6 @@ async fn put_settings(
config_manager.set_index_album_art_pattern(regex).await?; config_manager.set_index_album_art_pattern(regex).await?;
} }
if let Some(seconds) = new_settings.reindex_every_n_seconds {
config_manager
.set_index_sleep_duration(Duration::from_secs(seconds as u64))
.await?;
}
if let Some(url_string) = new_settings.ddns_update_url { if let Some(url_string) = new_settings.ddns_update_url {
let uri = match url_string.trim() { let uri = match url_string.trim() {
"" => None, "" => None,

View file

@ -160,14 +160,12 @@ impl From<config::MountDir> for MountDir {
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct NewSettings { pub struct NewSettings {
pub album_art_pattern: Option<String>, pub album_art_pattern: Option<String>,
pub reindex_every_n_seconds: Option<i64>,
pub ddns_update_url: Option<String>, pub ddns_update_url: Option<String>,
} }
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Settings { pub struct Settings {
pub album_art_pattern: String, pub album_art_pattern: String,
pub reindex_every_n_seconds: u64,
pub ddns_update_url: String, pub ddns_update_url: String,
} }

View file

@ -63,7 +63,6 @@ async fn put_settings_golden_path() {
let request = protocol::put_settings(dto::NewSettings { let request = protocol::put_settings(dto::NewSettings {
album_art_pattern: Some("test_pattern".to_owned()), album_art_pattern: Some("test_pattern".to_owned()),
reindex_every_n_seconds: Some(31),
ddns_update_url: Some("http://example.com/".to_owned()), ddns_update_url: Some("http://example.com/".to_owned()),
}); });
let response = service.fetch(&request).await; let response = service.fetch(&request).await;
@ -76,7 +75,6 @@ async fn put_settings_golden_path() {
settings, settings,
&Settings { &Settings {
album_art_pattern: "test_pattern".to_owned(), album_art_pattern: "test_pattern".to_owned(),
reindex_every_n_seconds: 31,
ddns_update_url: "http://example.com/".to_owned(), ddns_update_url: "http://example.com/".to_owned(),
}, },
); );