From bd5c1328da106dbd581d8e77afebcdbdccd786e9 Mon Sep 17 00:00:00 2001 From: Loong <40141251+wangl-cc@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:35:07 +0100 Subject: [PATCH] fix: ensure parent directory exists before writing to file --- maa-cli/src/run/preset/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/maa-cli/src/run/preset/mod.rs b/maa-cli/src/run/preset/mod.rs index 57ba4576..18ddfa03 100644 --- a/maa-cli/src/run/preset/mod.rs +++ b/maa-cli/src/run/preset/mod.rs @@ -117,6 +117,8 @@ mod tests { object, }; + use maa_dirs::Ensure; + impl MAAValue { /// Merge another value into this default value. /// @@ -158,6 +160,7 @@ mod tests { assert_eq!(task_config[0].params, object!()); let default = default_file(TaskType::Custom).with_extension("toml"); + default.parent().unwrap().ensure().unwrap(); let mut file = std::fs::File::create(&default).unwrap(); use std::io::Write; writeln!(file, "foo = 42").unwrap();