fix(cli config): create folder for config

This commit is contained in:
daimond113 2024-03-29 20:27:47 +01:00
parent 056d1dce36
commit 12407fa6de
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
3 changed files with 7 additions and 5 deletions

View file

@ -30,4 +30,4 @@ sentry-log = "0.32.2"
sentry-actix = "0.32.2"
# zstd-sys v2.0.10 is broken: https://github.com/gyscos/zstd-rs/issues/268
zstd-sys = "=2.0.9+zstd.1.5.5"
zstd-sys = "=2.0.9"

View file

@ -20,6 +20,7 @@ use reqwest::{
use semver::{Version, VersionReq};
use serde::{Deserialize, Serialize};
use std::{
fs::create_dir_all,
hash::{DefaultHasher, Hash, Hasher},
path::PathBuf,
str::FromStr,
@ -173,9 +174,10 @@ impl CliConfig {
}
pub fn write(&self) -> anyhow::Result<()> {
let cli_config_path = DIRS.config_dir().join("config.yaml");
let folder = DIRS.config_dir();
create_dir_all(folder)?;
serde_yaml::to_writer(
&mut std::fs::File::create(cli_config_path.as_path())?,
&mut std::fs::File::create(folder.join("config.yaml"))?,
&self,
)?;

View file

@ -110,7 +110,7 @@ pub enum EscapedPackageNameError<E> {
Invalid(String),
/// The package name is invalid
#[error("invalid package name")]
#[error(transparent)]
InvalidName(#[from] E),
}
@ -122,7 +122,7 @@ pub enum FromStrPackageNameParseError<E> {
Invalid(String),
/// The package name is invalid
#[error("invalid name part")]
#[error(transparent)]
InvalidPart(#[from] E),
}