Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create directories for history if they DNE #386

Merged
merged 2 commits into from
Mar 9, 2024
Merged

feat: create directories for history if they DNE #386

merged 2 commits into from
Mar 9, 2024

Conversation

hamirmahal
Copy link
Contributor

fixes #385.

history_path.to_string_lossy()
))?;
// Try to save the history, and if it fails because prerequisite directories don't exist, create them.
if let Err(e) = rl.save_history(&history_path) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking whether it fails, we could always call create_dir_all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that could be much cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if the latest changes are more or less what you had in mind.

@hamirmahal hamirmahal requested a review from sharkdp March 8, 2024 08:32
@sharkdp
Copy link
Owner

sharkdp commented Mar 9, 2024

We actually have a call to fs::create_dir in get_history_path. The problem seems to be that you didn't have a ~/.local/share folder at all? Is that possible?

I changed the fix to use fs::create_dir_all instead.

@sharkdp sharkdp merged commit f574c37 into sharkdp:master Mar 9, 2024
15 checks passed
@hamirmahal hamirmahal deleted the feat/create-directories-for-history-if-they-dont-exist branch March 10, 2024 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create data folder if it does not exist
2 participants