Desktop: fix bug when not creating config dir

This commit is contained in:
Igor Katson 2023-12-07 16:18:18 +00:00
parent 2fdea72702
commit a5e7a5a5f5
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 7 additions and 4 deletions

View file

@ -6,6 +6,7 @@ mod config;
use std::{
fs::{File, OpenOptions},
io::{BufReader, BufWriter},
path::Path,
sync::Arc,
};
@ -49,6 +50,8 @@ fn read_config(path: &str) -> anyhow::Result<RqbitDesktopConfig> {
}
fn write_config(path: &str, config: &RqbitDesktopConfig) -> anyhow::Result<()> {
std::fs::create_dir_all(Path::new(path).parent().context("no parent")?)
.context("error creating dirs")?;
let tmp = format!("{}.tmp", path);
let mut tmp_file = BufWriter::new(
OpenOptions::new()