Explorar o código

util/cli: create ~/.local directory for log file if it's not exist

ghassmo %!s(int64=4) %!d(string=hai) anos
pai
achega
75c21bb59c
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      src/util/cli.rs

+ 4 - 1
src/util/cli.rs

@@ -167,7 +167,10 @@ macro_rules! async_daemonize {
 
             let log_file_path = match std::env::var("DARKFI_LOG") {
                 Ok(p) => p,
-                Err(_) => "~/.local/darkfi.log".into(),
+                Err(_) => {
+                    std::fs::create_dir_all(expand_path("~/.local")?)?;
+                    "~/.local/darkfi.log".into()
+                }
             };
 
             let log_file_path = expand_path(&log_file_path)?;