mirror of
https://github.com/agersant/polaris
synced 2024-12-02 01:29:09 +00:00
Do not wipe users, mount points and ddns config before applying config file
This commit is contained in:
parent
bca8f4ced8
commit
28bb240ae0
3 changed files with 10 additions and 15 deletions
|
@ -134,7 +134,8 @@ where
|
|||
Ok(config)
|
||||
}
|
||||
|
||||
fn reset<T>(db: &T) -> Result<()>
|
||||
#[cfg(test)]
|
||||
pub fn reset<T>(db: &T) -> Result<()>
|
||||
where
|
||||
T: ConnectionSource,
|
||||
{
|
||||
|
@ -150,14 +151,6 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn overwrite<T>(db: &T, new_config: &Config) -> Result<()>
|
||||
where
|
||||
T: ConnectionSource,
|
||||
{
|
||||
reset(db)?;
|
||||
amend(db, new_config)
|
||||
}
|
||||
|
||||
pub fn amend<T>(db: &T, new_config: &Config) -> Result<()>
|
||||
where
|
||||
T: ConnectionSource,
|
||||
|
|
|
@ -4,8 +4,7 @@ use diesel::sqlite::SqliteConnection;
|
|||
use diesel_migrations;
|
||||
use error_chain::bail;
|
||||
use log::info;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
|
||||
use crate::errors::*;
|
||||
|
@ -86,20 +85,22 @@ impl ConnectionSource for DB {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn _get_test_db(name: &str) -> DB {
|
||||
use crate::config;
|
||||
let config_path = Path::new("test/config.toml");
|
||||
let config = config::parse_toml_file(&config_path).unwrap();
|
||||
|
||||
let mut db_path = PathBuf::new();
|
||||
let mut db_path = std::path::PathBuf::new();
|
||||
db_path.push("test");
|
||||
db_path.push(name);
|
||||
if db_path.exists() {
|
||||
fs::remove_file(&db_path).unwrap();
|
||||
std::fs::remove_file(&db_path).unwrap();
|
||||
}
|
||||
|
||||
let db = DB::new(&db_path).unwrap();
|
||||
config::overwrite(&db, &config).unwrap();
|
||||
config::reset(&db).unwrap();
|
||||
config::amend(&db, &config).unwrap();
|
||||
db
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,8 @@ fn run() -> Result<()> {
|
|||
let config_file_path = config_file_name.map(|p| Path::new(p.as_str()).to_path_buf());
|
||||
if let Some(path) = config_file_path {
|
||||
let config = config::parse_toml_file(&path)?;
|
||||
config::overwrite(db.deref(), &config)?;
|
||||
info!("Applying configuration");
|
||||
config::amend(db.deref(), &config)?;
|
||||
}
|
||||
let config = config::read(db.deref())?;
|
||||
let auth_secret = config::get_auth_secret(db.deref())?;
|
||||
|
|
Loading…
Reference in a new issue