Skip to content

Commit

Permalink
creates the directory containing the history file, if it doesn't exis…
Browse files Browse the repository at this point in the history
…t now
  • Loading branch information
KnorrFG committed Nov 26, 2023
1 parent d6ae078 commit fe473a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dotree"
version = "0.8.0"
version = "0.8.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
6 changes: 4 additions & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ fn store_hist(hist: Vec<String>) -> Result<()> {
let line_ending = "\r\n";
#[cfg(not(windows))]
let line_ending = "\n";

fs::write(get_hist_path()?, hist.join(line_ending))?;
let hist_path = get_hist_path()?;
fs::create_dir_all(hist_path.parent().context("Getting history file dir")?)
.context("creating history file dir")?;
fs::write(hist_path, hist.join(line_ending))?;
Ok(())
}

Expand Down

0 comments on commit fe473a6

Please sign in to comment.