Removed support for prefix_url

This commit is contained in:
Antoine Gersant 2020-11-25 17:49:18 -08:00
parent 1c5a536277
commit e0d1f396a8
7 changed files with 86 additions and 101 deletions

View file

@ -827,9 +827,6 @@
"$ref": "#/components/schemas/MountPoint"
}
},
"prefix_url": {
"type": "string"
},
"users": {
"type": "array",
"items": {

View file

@ -0,0 +1 @@
ALTER TABLE misc_settings ADD COLUMN prefix_url TEXT NOT NULL DEFAULT "";

View file

@ -0,0 +1,11 @@
CREATE TEMPORARY TABLE misc_settings_backup(id, auth_secret, index_sleep_duration_seconds, index_album_art_pattern);
INSERT INTO misc_settings_backup SELECT id, auth_secret, index_sleep_duration_seconds, index_album_art_pattern FROM misc_settings;
DROP TABLE misc_settings;
CREATE TABLE misc_settings (
id INTEGER PRIMARY KEY NOT NULL CHECK(id = 0),
auth_secret BLOB NOT NULL DEFAULT (randomblob(32)),
index_sleep_duration_seconds INTEGER NOT NULL,
index_album_art_pattern TEXT NOT NULL
);
INSERT INTO misc_settings SELECT * FROM misc_settings_backup;
DROP TABLE misc_settings_backup;

View file

@ -21,7 +21,6 @@ pub struct MiscSettings {
pub auth_secret: Vec<u8>,
pub index_sleep_duration_seconds: i32,
pub index_album_art_pattern: String,
pub prefix_url: String,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
@ -43,7 +42,6 @@ pub struct Config {
pub album_art_pattern: Option<String>,
pub reindex_every_n_seconds: Option<i32>,
pub mount_dirs: Option<Vec<MountPoint>>,
pub prefix_url: Option<String>,
pub users: Option<Vec<ConfigUser>>,
pub ydns: Option<DDNSConfig>,
}
@ -82,22 +80,19 @@ pub fn read(db: &DB) -> Result<Config> {
album_art_pattern: None,
reindex_every_n_seconds: None,
mount_dirs: None,
prefix_url: None,
users: None,
ydns: None,
};
let (art_pattern, sleep_duration, url) = misc_settings
let (art_pattern, sleep_duration) = misc_settings
.select((
index_album_art_pattern,
index_sleep_duration_seconds,
prefix_url,
))
.get_result(&connection)?;
config.album_art_pattern = Some(art_pattern);
config.reindex_every_n_seconds = Some(sleep_duration);
config.prefix_url = if url != "" { Some(url) } else { None };
let mount_dirs;
{
@ -226,12 +221,6 @@ pub fn amend(db: &DB, new_config: &Config) -> Result<()> {
.execute(&connection)?;
}
if let Some(ref prefix_url) = new_config.prefix_url {
diesel::update(misc_settings::table)
.set(misc_settings::prefix_url.eq(prefix_url))
.execute(&connection)?;
}
Ok(())
}
@ -302,7 +291,6 @@ fn test_amend() {
let initial_config = Config {
album_art_pattern: Some("file\\.png".into()),
reindex_every_n_seconds: Some(123),
prefix_url: None,
mount_dirs: Some(vec![MountPoint {
source: "C:\\Music".into(),
name: "root".into(),
@ -318,7 +306,6 @@ fn test_amend() {
let new_config = Config {
album_art_pattern: Some("🖼️\\.jpg".into()),
reindex_every_n_seconds: None,
prefix_url: Some("polaris".into()),
mount_dirs: Some(vec![MountPoint {
source: "/home/music".into(),
name: "🎵📁".into(),
@ -358,7 +345,6 @@ fn test_amend_preserve_password_hashes() {
let initial_config = Config {
album_art_pattern: None,
reindex_every_n_seconds: None,
prefix_url: None,
mount_dirs: None,
users: Some(vec![ConfigUser {
name: "Teddy🐻".into(),
@ -381,7 +367,6 @@ fn test_amend_preserve_password_hashes() {
let new_config = Config {
album_art_pattern: None,
reindex_every_n_seconds: None,
prefix_url: None,
mount_dirs: None,
users: Some(vec![
ConfigUser {
@ -421,7 +406,6 @@ fn test_amend_ignore_blank_users() {
let config = Config {
album_art_pattern: None,
reindex_every_n_seconds: None,
prefix_url: None,
mount_dirs: None,
users: Some(vec![ConfigUser {
name: "".into(),
@ -441,7 +425,6 @@ fn test_amend_ignore_blank_users() {
let config = Config {
album_art_pattern: None,
reindex_every_n_seconds: None,
prefix_url: None,
mount_dirs: None,
users: Some(vec![ConfigUser {
name: "Teddy🐻".into(),
@ -467,7 +450,6 @@ fn test_toggle_admin() {
let initial_config = Config {
album_art_pattern: None,
reindex_every_n_seconds: None,
prefix_url: None,
mount_dirs: None,
users: Some(vec![ConfigUser {
name: "Teddy🐻".into(),
@ -487,7 +469,6 @@ fn test_toggle_admin() {
let new_config = Config {
album_art_pattern: None,
reindex_every_n_seconds: None,
prefix_url: None,
mount_dirs: None,
users: Some(vec![ConfigUser {
name: "Teddy🐻".into(),
@ -512,7 +493,6 @@ fn test_preferences_read_write() {
let initial_config = Config {
album_art_pattern: None,
reindex_every_n_seconds: None,
prefix_url: None,
mount_dirs: None,
users: Some(vec![ConfigUser {
name: "Teddy🐻".into(),

View file

@ -1,100 +1,99 @@
table! {
ddns_config (id) {
id -> Integer,
host -> Text,
username -> Text,
password -> Text,
}
ddns_config (id) {
id -> Integer,
host -> Text,
username -> Text,
password -> Text,
}
}
table! {
directories (id) {
id -> Integer,
path -> Text,
parent -> Nullable<Text>,
artist -> Nullable<Text>,
year -> Nullable<Integer>,
album -> Nullable<Text>,
artwork -> Nullable<Text>,
date_added -> Integer,
}
directories (id) {
id -> Integer,
path -> Text,
parent -> Nullable<Text>,
artist -> Nullable<Text>,
year -> Nullable<Integer>,
album -> Nullable<Text>,
artwork -> Nullable<Text>,
date_added -> Integer,
}
}
table! {
misc_settings (id) {
id -> Integer,
auth_secret -> Binary,
index_sleep_duration_seconds -> Integer,
index_album_art_pattern -> Text,
prefix_url -> Text,
}
misc_settings (id) {
id -> Integer,
auth_secret -> Binary,
index_sleep_duration_seconds -> Integer,
index_album_art_pattern -> Text,
}
}
table! {
mount_points (id) {
id -> Integer,
source -> Text,
name -> Text,
}
mount_points (id) {
id -> Integer,
source -> Text,
name -> Text,
}
}
table! {
playlist_songs (id) {
id -> Integer,
playlist -> Integer,
path -> Text,
ordering -> Integer,
}
playlist_songs (id) {
id -> Integer,
playlist -> Integer,
path -> Text,
ordering -> Integer,
}
}
table! {
playlists (id) {
id -> Integer,
owner -> Integer,
name -> Text,
}
playlists (id) {
id -> Integer,
owner -> Integer,
name -> Text,
}
}
table! {
songs (id) {
id -> Integer,
path -> Text,
parent -> Text,
track_number -> Nullable<Integer>,
disc_number -> Nullable<Integer>,
title -> Nullable<Text>,
artist -> Nullable<Text>,
album_artist -> Nullable<Text>,
year -> Nullable<Integer>,
album -> Nullable<Text>,
artwork -> Nullable<Text>,
duration -> Nullable<Integer>,
}
songs (id) {
id -> Integer,
path -> Text,
parent -> Text,
track_number -> Nullable<Integer>,
disc_number -> Nullable<Integer>,
title -> Nullable<Text>,
artist -> Nullable<Text>,
album_artist -> Nullable<Text>,
year -> Nullable<Integer>,
album -> Nullable<Text>,
artwork -> Nullable<Text>,
duration -> Nullable<Integer>,
}
}
table! {
users (id) {
id -> Integer,
name -> Text,
password_hash -> Text,
admin -> Integer,
lastfm_username -> Nullable<Text>,
lastfm_session_key -> Nullable<Text>,
web_theme_base -> Nullable<Text>,
web_theme_accent -> Nullable<Text>,
}
users (id) {
id -> Integer,
name -> Text,
password_hash -> Text,
admin -> Integer,
lastfm_username -> Nullable<Text>,
lastfm_session_key -> Nullable<Text>,
web_theme_base -> Nullable<Text>,
web_theme_accent -> Nullable<Text>,
}
}
joinable!(playlist_songs -> playlists (playlist));
joinable!(playlists -> users (owner));
allow_tables_to_appear_in_same_query!(
ddns_config,
directories,
misc_settings,
mount_points,
playlist_songs,
playlists,
songs,
users,
ddns_config,
directories,
misc_settings,
mount_points,
playlist_songs,
playlists,
songs,
users,
);

View file

@ -169,7 +169,6 @@ fn main() -> Result<()> {
info!("Applying configuration");
config::amend(&db, &config)?;
}
let config = config::read(&db)?;
let auth_secret = config::get_auth_secret(&db)?;
// Init index
@ -177,8 +176,7 @@ fn main() -> Result<()> {
let index = index::builder(db.clone()).periodic_updates(true).build();
// API mount target
let prefix_url = config.prefix_url.unwrap_or_else(|| "".to_string());
let api_url = format!("/{}api", &prefix_url);
let api_url = "/api".to_owned();
info!("Mounting API on {}", api_url);
// Web client mount target
@ -189,7 +187,7 @@ fn main() -> Result<()> {
.map(|n| Path::new(n.as_str()).to_path_buf())
.unwrap_or(default_web_dir);
info!("Static files location is {}", web_dir_path.display());
let web_url = format!("/{}", &prefix_url);
let web_url = "/".to_owned();
info!("Mounting web client files on {}", web_url);
// Swagger files mount target
@ -200,7 +198,7 @@ fn main() -> Result<()> {
.map(|n| Path::new(n.as_str()).to_path_buf())
.unwrap_or(default_swagger_dir);
info!("Swagger files location is {}", swagger_dir_path.display());
let swagger_url = format!("/{}swagger", &prefix_url);
let swagger_url = "/swagger".to_owned();
info!("Mounting swagger files on {}", swagger_url);
// Thumbnails manager

View file

@ -33,7 +33,6 @@ pub trait TestService {
fn complete_initial_setup(&mut self) {
let configuration = config::Config {
album_art_pattern: None,
prefix_url: None,
reindex_every_n_seconds: None,
ydns: None,
users: Some(vec![config::ConfigUser {