Fix DB related bugs

This commit is contained in:
Raphaël Thériault 2019-10-25 14:13:44 -04:00
parent 8a704eb283
commit 212ac3617f
2 changed files with 13 additions and 5 deletions

View File

@ -50,10 +50,12 @@ fn main() {
let pool = setup::create_pool(&config.database_url, config.pool_size);
#[cfg(not(feature = "dev"))]
embedded_migrations::run(&pool.get().unwrap()).unwrap_or_else(|e| {
eprintln!("Can't prepare database: {}.", e);
process::exit(1);
});
{
embedded_migrations::run(&pool.get().unwrap()).unwrap_or_else(|e| {
eprintln!("Can't prepare database: {}.", e);
process::exit(1);
});
}
let password_hash = {
#[cfg(feature = "dev")]

View File

@ -99,7 +99,13 @@ impl Default for Config {
.expect("Can't convert database path to string")
.to_owned()
};
let pool_size = num_cpus::get() as u32 / 2;
let pool_size = {
let n = num_cpus::get() as u32 / 2;
match n < 1 {
true => 1,
false => n,
}
};
let files_dir = {
let mut path = get_data_dir();
path.push("files");