mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
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:
parent
0ca3d51f29
commit
47b06658b0
@ -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
|
||||
};
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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| {
|
||||
|
Loading…
Reference in New Issue
Block a user