Removed support for prefix_url
This commit is contained in:
parent
1c5a536277
commit
e0d1f396a8
7 changed files with 86 additions and 101 deletions
|
@ -827,9 +827,6 @@
|
||||||
"$ref": "#/components/schemas/MountPoint"
|
"$ref": "#/components/schemas/MountPoint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"prefix_url": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"users": {
|
"users": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
1
migrations/2020-11-25-174000_remove_prefix_url/down.sql
Normal file
1
migrations/2020-11-25-174000_remove_prefix_url/down.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE misc_settings ADD COLUMN prefix_url TEXT NOT NULL DEFAULT "";
|
11
migrations/2020-11-25-174000_remove_prefix_url/up.sql
Normal file
11
migrations/2020-11-25-174000_remove_prefix_url/up.sql
Normal 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;
|
|
@ -21,7 +21,6 @@ pub struct MiscSettings {
|
||||||
pub auth_secret: Vec<u8>,
|
pub auth_secret: Vec<u8>,
|
||||||
pub index_sleep_duration_seconds: i32,
|
pub index_sleep_duration_seconds: i32,
|
||||||
pub index_album_art_pattern: String,
|
pub index_album_art_pattern: String,
|
||||||
pub prefix_url: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||||
|
@ -43,7 +42,6 @@ pub struct Config {
|
||||||
pub album_art_pattern: Option<String>,
|
pub album_art_pattern: Option<String>,
|
||||||
pub reindex_every_n_seconds: Option<i32>,
|
pub reindex_every_n_seconds: Option<i32>,
|
||||||
pub mount_dirs: Option<Vec<MountPoint>>,
|
pub mount_dirs: Option<Vec<MountPoint>>,
|
||||||
pub prefix_url: Option<String>,
|
|
||||||
pub users: Option<Vec<ConfigUser>>,
|
pub users: Option<Vec<ConfigUser>>,
|
||||||
pub ydns: Option<DDNSConfig>,
|
pub ydns: Option<DDNSConfig>,
|
||||||
}
|
}
|
||||||
|
@ -82,22 +80,19 @@ pub fn read(db: &DB) -> Result<Config> {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
mount_dirs: None,
|
mount_dirs: None,
|
||||||
prefix_url: None,
|
|
||||||
users: None,
|
users: None,
|
||||||
ydns: None,
|
ydns: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (art_pattern, sleep_duration, url) = misc_settings
|
let (art_pattern, sleep_duration) = misc_settings
|
||||||
.select((
|
.select((
|
||||||
index_album_art_pattern,
|
index_album_art_pattern,
|
||||||
index_sleep_duration_seconds,
|
index_sleep_duration_seconds,
|
||||||
prefix_url,
|
|
||||||
))
|
))
|
||||||
.get_result(&connection)?;
|
.get_result(&connection)?;
|
||||||
|
|
||||||
config.album_art_pattern = Some(art_pattern);
|
config.album_art_pattern = Some(art_pattern);
|
||||||
config.reindex_every_n_seconds = Some(sleep_duration);
|
config.reindex_every_n_seconds = Some(sleep_duration);
|
||||||
config.prefix_url = if url != "" { Some(url) } else { None };
|
|
||||||
|
|
||||||
let mount_dirs;
|
let mount_dirs;
|
||||||
{
|
{
|
||||||
|
@ -226,12 +221,6 @@ pub fn amend(db: &DB, new_config: &Config) -> Result<()> {
|
||||||
.execute(&connection)?;
|
.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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +291,6 @@ fn test_amend() {
|
||||||
let initial_config = Config {
|
let initial_config = Config {
|
||||||
album_art_pattern: Some("file\\.png".into()),
|
album_art_pattern: Some("file\\.png".into()),
|
||||||
reindex_every_n_seconds: Some(123),
|
reindex_every_n_seconds: Some(123),
|
||||||
prefix_url: None,
|
|
||||||
mount_dirs: Some(vec![MountPoint {
|
mount_dirs: Some(vec![MountPoint {
|
||||||
source: "C:\\Music".into(),
|
source: "C:\\Music".into(),
|
||||||
name: "root".into(),
|
name: "root".into(),
|
||||||
|
@ -318,7 +306,6 @@ fn test_amend() {
|
||||||
let new_config = Config {
|
let new_config = Config {
|
||||||
album_art_pattern: Some("🖼️\\.jpg".into()),
|
album_art_pattern: Some("🖼️\\.jpg".into()),
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
prefix_url: Some("polaris".into()),
|
|
||||||
mount_dirs: Some(vec![MountPoint {
|
mount_dirs: Some(vec![MountPoint {
|
||||||
source: "/home/music".into(),
|
source: "/home/music".into(),
|
||||||
name: "🎵📁".into(),
|
name: "🎵📁".into(),
|
||||||
|
@ -358,7 +345,6 @@ fn test_amend_preserve_password_hashes() {
|
||||||
let initial_config = Config {
|
let initial_config = Config {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
prefix_url: None,
|
|
||||||
mount_dirs: None,
|
mount_dirs: None,
|
||||||
users: Some(vec![ConfigUser {
|
users: Some(vec![ConfigUser {
|
||||||
name: "Teddy🐻".into(),
|
name: "Teddy🐻".into(),
|
||||||
|
@ -381,7 +367,6 @@ fn test_amend_preserve_password_hashes() {
|
||||||
let new_config = Config {
|
let new_config = Config {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
prefix_url: None,
|
|
||||||
mount_dirs: None,
|
mount_dirs: None,
|
||||||
users: Some(vec![
|
users: Some(vec![
|
||||||
ConfigUser {
|
ConfigUser {
|
||||||
|
@ -421,7 +406,6 @@ fn test_amend_ignore_blank_users() {
|
||||||
let config = Config {
|
let config = Config {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
prefix_url: None,
|
|
||||||
mount_dirs: None,
|
mount_dirs: None,
|
||||||
users: Some(vec![ConfigUser {
|
users: Some(vec![ConfigUser {
|
||||||
name: "".into(),
|
name: "".into(),
|
||||||
|
@ -441,7 +425,6 @@ fn test_amend_ignore_blank_users() {
|
||||||
let config = Config {
|
let config = Config {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
prefix_url: None,
|
|
||||||
mount_dirs: None,
|
mount_dirs: None,
|
||||||
users: Some(vec![ConfigUser {
|
users: Some(vec![ConfigUser {
|
||||||
name: "Teddy🐻".into(),
|
name: "Teddy🐻".into(),
|
||||||
|
@ -467,7 +450,6 @@ fn test_toggle_admin() {
|
||||||
let initial_config = Config {
|
let initial_config = Config {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
prefix_url: None,
|
|
||||||
mount_dirs: None,
|
mount_dirs: None,
|
||||||
users: Some(vec![ConfigUser {
|
users: Some(vec![ConfigUser {
|
||||||
name: "Teddy🐻".into(),
|
name: "Teddy🐻".into(),
|
||||||
|
@ -487,7 +469,6 @@ fn test_toggle_admin() {
|
||||||
let new_config = Config {
|
let new_config = Config {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
prefix_url: None,
|
|
||||||
mount_dirs: None,
|
mount_dirs: None,
|
||||||
users: Some(vec![ConfigUser {
|
users: Some(vec![ConfigUser {
|
||||||
name: "Teddy🐻".into(),
|
name: "Teddy🐻".into(),
|
||||||
|
@ -512,7 +493,6 @@ fn test_preferences_read_write() {
|
||||||
let initial_config = Config {
|
let initial_config = Config {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
prefix_url: None,
|
|
||||||
mount_dirs: None,
|
mount_dirs: None,
|
||||||
users: Some(vec![ConfigUser {
|
users: Some(vec![ConfigUser {
|
||||||
name: "Teddy🐻".into(),
|
name: "Teddy🐻".into(),
|
||||||
|
|
141
src/db/schema.rs
141
src/db/schema.rs
|
@ -1,100 +1,99 @@
|
||||||
table! {
|
table! {
|
||||||
ddns_config (id) {
|
ddns_config (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
host -> Text,
|
host -> Text,
|
||||||
username -> Text,
|
username -> Text,
|
||||||
password -> Text,
|
password -> Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
directories (id) {
|
directories (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
path -> Text,
|
path -> Text,
|
||||||
parent -> Nullable<Text>,
|
parent -> Nullable<Text>,
|
||||||
artist -> Nullable<Text>,
|
artist -> Nullable<Text>,
|
||||||
year -> Nullable<Integer>,
|
year -> Nullable<Integer>,
|
||||||
album -> Nullable<Text>,
|
album -> Nullable<Text>,
|
||||||
artwork -> Nullable<Text>,
|
artwork -> Nullable<Text>,
|
||||||
date_added -> Integer,
|
date_added -> Integer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
misc_settings (id) {
|
misc_settings (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
auth_secret -> Binary,
|
auth_secret -> Binary,
|
||||||
index_sleep_duration_seconds -> Integer,
|
index_sleep_duration_seconds -> Integer,
|
||||||
index_album_art_pattern -> Text,
|
index_album_art_pattern -> Text,
|
||||||
prefix_url -> Text,
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
mount_points (id) {
|
mount_points (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
source -> Text,
|
source -> Text,
|
||||||
name -> Text,
|
name -> Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
playlist_songs (id) {
|
playlist_songs (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
playlist -> Integer,
|
playlist -> Integer,
|
||||||
path -> Text,
|
path -> Text,
|
||||||
ordering -> Integer,
|
ordering -> Integer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
playlists (id) {
|
playlists (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
owner -> Integer,
|
owner -> Integer,
|
||||||
name -> Text,
|
name -> Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
songs (id) {
|
songs (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
path -> Text,
|
path -> Text,
|
||||||
parent -> Text,
|
parent -> Text,
|
||||||
track_number -> Nullable<Integer>,
|
track_number -> Nullable<Integer>,
|
||||||
disc_number -> Nullable<Integer>,
|
disc_number -> Nullable<Integer>,
|
||||||
title -> Nullable<Text>,
|
title -> Nullable<Text>,
|
||||||
artist -> Nullable<Text>,
|
artist -> Nullable<Text>,
|
||||||
album_artist -> Nullable<Text>,
|
album_artist -> Nullable<Text>,
|
||||||
year -> Nullable<Integer>,
|
year -> Nullable<Integer>,
|
||||||
album -> Nullable<Text>,
|
album -> Nullable<Text>,
|
||||||
artwork -> Nullable<Text>,
|
artwork -> Nullable<Text>,
|
||||||
duration -> Nullable<Integer>,
|
duration -> Nullable<Integer>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
users (id) {
|
users (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
name -> Text,
|
name -> Text,
|
||||||
password_hash -> Text,
|
password_hash -> Text,
|
||||||
admin -> Integer,
|
admin -> Integer,
|
||||||
lastfm_username -> Nullable<Text>,
|
lastfm_username -> Nullable<Text>,
|
||||||
lastfm_session_key -> Nullable<Text>,
|
lastfm_session_key -> Nullable<Text>,
|
||||||
web_theme_base -> Nullable<Text>,
|
web_theme_base -> Nullable<Text>,
|
||||||
web_theme_accent -> Nullable<Text>,
|
web_theme_accent -> Nullable<Text>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
joinable!(playlist_songs -> playlists (playlist));
|
joinable!(playlist_songs -> playlists (playlist));
|
||||||
joinable!(playlists -> users (owner));
|
joinable!(playlists -> users (owner));
|
||||||
|
|
||||||
allow_tables_to_appear_in_same_query!(
|
allow_tables_to_appear_in_same_query!(
|
||||||
ddns_config,
|
ddns_config,
|
||||||
directories,
|
directories,
|
||||||
misc_settings,
|
misc_settings,
|
||||||
mount_points,
|
mount_points,
|
||||||
playlist_songs,
|
playlist_songs,
|
||||||
playlists,
|
playlists,
|
||||||
songs,
|
songs,
|
||||||
users,
|
users,
|
||||||
);
|
);
|
||||||
|
|
|
@ -169,7 +169,6 @@ fn main() -> Result<()> {
|
||||||
info!("Applying configuration");
|
info!("Applying configuration");
|
||||||
config::amend(&db, &config)?;
|
config::amend(&db, &config)?;
|
||||||
}
|
}
|
||||||
let config = config::read(&db)?;
|
|
||||||
let auth_secret = config::get_auth_secret(&db)?;
|
let auth_secret = config::get_auth_secret(&db)?;
|
||||||
|
|
||||||
// Init index
|
// Init index
|
||||||
|
@ -177,8 +176,7 @@ fn main() -> Result<()> {
|
||||||
let index = index::builder(db.clone()).periodic_updates(true).build();
|
let index = index::builder(db.clone()).periodic_updates(true).build();
|
||||||
|
|
||||||
// API mount target
|
// API mount target
|
||||||
let prefix_url = config.prefix_url.unwrap_or_else(|| "".to_string());
|
let api_url = "/api".to_owned();
|
||||||
let api_url = format!("/{}api", &prefix_url);
|
|
||||||
info!("Mounting API on {}", api_url);
|
info!("Mounting API on {}", api_url);
|
||||||
|
|
||||||
// Web client mount target
|
// Web client mount target
|
||||||
|
@ -189,7 +187,7 @@ fn main() -> Result<()> {
|
||||||
.map(|n| Path::new(n.as_str()).to_path_buf())
|
.map(|n| Path::new(n.as_str()).to_path_buf())
|
||||||
.unwrap_or(default_web_dir);
|
.unwrap_or(default_web_dir);
|
||||||
info!("Static files location is {}", web_dir_path.display());
|
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);
|
info!("Mounting web client files on {}", web_url);
|
||||||
|
|
||||||
// Swagger files mount target
|
// Swagger files mount target
|
||||||
|
@ -200,7 +198,7 @@ fn main() -> Result<()> {
|
||||||
.map(|n| Path::new(n.as_str()).to_path_buf())
|
.map(|n| Path::new(n.as_str()).to_path_buf())
|
||||||
.unwrap_or(default_swagger_dir);
|
.unwrap_or(default_swagger_dir);
|
||||||
info!("Swagger files location is {}", swagger_dir_path.display());
|
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);
|
info!("Mounting swagger files on {}", swagger_url);
|
||||||
|
|
||||||
// Thumbnails manager
|
// Thumbnails manager
|
||||||
|
|
|
@ -33,7 +33,6 @@ pub trait TestService {
|
||||||
fn complete_initial_setup(&mut self) {
|
fn complete_initial_setup(&mut self) {
|
||||||
let configuration = config::Config {
|
let configuration = config::Config {
|
||||||
album_art_pattern: None,
|
album_art_pattern: None,
|
||||||
prefix_url: None,
|
|
||||||
reindex_every_n_seconds: None,
|
reindex_every_n_seconds: None,
|
||||||
ydns: None,
|
ydns: None,
|
||||||
users: Some(vec![config::ConfigUser {
|
users: Some(vec![config::ConfigUser {
|
||||||
|
|
Loading…
Add table
Reference in a new issue