Merge branch 'xvar/fix-saves-dir-creation' into 'master'

Fixed initial creation of saves directory

See merge request veloren/veloren!2122
This commit is contained in:
Ben Wallis 2021-04-14 07:41:59 +00:00
commit 6db79d5439
2 changed files with 8 additions and 2 deletions

View File

@ -12,6 +12,7 @@ use common::comp;
use refinery::Report;
use rusqlite::{Connection, OpenFlags};
use std::{
fs,
path::PathBuf,
sync::{Arc, RwLock},
time::Duration,
@ -130,6 +131,10 @@ fn rusqlite_profile_callback(log_message: &str, dur: Duration) {
}
pub(crate) fn establish_connection(settings: &DatabaseSettings) -> VelorenConnection {
fs::create_dir_all(&settings.db_dir).expect(&*format!(
"Failed to create saves directory: {:?}",
&settings.db_dir
));
let connection = Connection::open_with_flags(
&settings.db_dir.join("db.sqlite"),
OpenFlags::SQLITE_OPEN_PRIVATE_CACHE | OpenFlags::default(),

View File

@ -62,8 +62,9 @@ impl Singleplayer {
};
info!(
"Saves folder doesn't exist, but there is one in the old saves location, copying \
it to the new location"
"Saves folder doesn't exist, but there is one in the old saves location ({}), \
copying it to the new location",
old_path.display()
);
if let Some(parent) = new_path.parent() {
if let Err(e) = std::fs::create_dir_all(parent) {