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

@ -1867,7 +1867,7 @@ dependencies = [
[[package]] [[package]]
name = "librqbit" name = "librqbit"
version = "5.0.0-beta.1" version = "5.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"axum", "axum",
@ -1933,7 +1933,7 @@ version = "2.2.1"
[[package]] [[package]]
name = "librqbit-core" name = "librqbit-core"
version = "3.3.0" version = "3.4.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"directories", "directories",
@ -1953,7 +1953,7 @@ dependencies = [
[[package]] [[package]]
name = "librqbit-dht" name = "librqbit-dht"
version = "5.0.0-beta.1" version = "5.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"backoff", "backoff",
@ -1978,7 +1978,7 @@ dependencies = [
[[package]] [[package]]
name = "librqbit-peer-protocol" name = "librqbit-peer-protocol"
version = "3.3.0" version = "3.4.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",

View file

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