Log where the userdata folder is in binary crates, fix bug where the old

path was logged instead of the new path when renaming invalid settings
This commit is contained in:
Imbris 2020-10-25 16:19:39 -04:00
parent 0ca3d51f29
commit 47b06658b0
4 changed files with 14 additions and 5 deletions

View File

@ -85,6 +85,7 @@ fn main() -> io::Result<()> {
// Determine folder to save server data in
let server_data_dir = {
let mut path = common::userdata_dir_workspace!();
info!("Using userdata folder at {}", path.display());
path.push(server::DEFAULT_DATA_DIR_NAME);
path
};

View File

@ -72,13 +72,15 @@ impl Settings {
match ron::de::from_reader(file) {
Ok(x) => x,
Err(e) => {
let default_settings = Self::default();
let template_path = path.with_extension("template.ron");
warn!(
?e,
"Failed to parse setting file! Falling back to default settings and \
creating a template file for you to migrate your current settings file"
creating a template file for you to migrate your current settings file: \
{}",
template_path.display()
);
let default_settings = Self::default();
let template_path = path.with_extension("template.ron");
if let Err(e) = default_settings.save_to_file(&template_path) {
error!(?e, "Failed to create template settings file")
}

View File

@ -37,7 +37,7 @@ pub trait EditableSetting: Serialize + DeserializeOwned + Default {
new_path = path.with_extension(format!("invalid{}.ron", i));
}
warn!("Renaming invalid settings file to: {}", path.display());
warn!("Renaming invalid settings file to: {}", new_path.display());
if let Err(e) = fs::rename(&path, &new_path) {
warn!(?e, ?path, ?new_path, "Failed to rename settings file.");
}

View File

@ -19,7 +19,7 @@ use common::{
clock::Clock,
};
use std::panic;
use tracing::{error, warn};
use tracing::{error, info, warn};
fn main() {
// Load the settings
@ -35,6 +35,12 @@ fn main() {
// Init logging and hold the guards.
let _guards = logging::init(&settings);
if let Some(path) = veloren_voxygen::settings::voxygen_data_dir().parent() {
info!("Using userdata dir at: {}", path.display());
} else {
error!("Can't log userdata dir, voxygen data dir has no parent!");
}
// Set up panic handler to relay swish panic messages to the user
let default_hook = panic::take_hook();
panic::set_hook(Box::new(move |panic_info| {