mirror of
https://github.com/forkless/NotAlterra.git
synced 2026-08-16 08:36:37 +02:00
scaffold backup dirs at startup, ensure_dir helper
This commit is contained in:
@@ -55,6 +55,11 @@ pub fn backups_config_dir() -> PathBuf {
|
|||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ensure a directory exists, creating all parents as needed.
|
||||||
|
pub fn ensure_dir(path: PathBuf) {
|
||||||
|
let _ = std::fs::create_dir_all(&path);
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the directory containing the running executable.
|
/// Return the directory containing the running executable.
|
||||||
pub fn exe_dir() -> PathBuf {
|
pub fn exe_dir() -> PathBuf {
|
||||||
std::env::current_exe()
|
std::env::current_exe()
|
||||||
|
|||||||
@@ -156,6 +156,10 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>) -> Result<()> {
|
|||||||
result in incomplete, corrupt, or overwritten save files.",
|
result in incomplete, corrupt, or overwritten save files.",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
// Scaffold backup directory structure
|
||||||
|
crate::config::ensure_dir(crate::config::backups_saves_dir());
|
||||||
|
crate::config::ensure_dir(crate::config::backups_config_dir());
|
||||||
|
|
||||||
// Migrate old transaction.log into logs/ directory
|
// Migrate old transaction.log into logs/ directory
|
||||||
if guard::migrate_old_log() {
|
if guard::migrate_old_log() {
|
||||||
guard::log_action("MIGRATE", "old transaction.log moved to logs/", "OK", &app.log_path)?;
|
guard::log_action("MIGRATE", "old transaction.log moved to logs/", "OK", &app.log_path)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user