From 12407fa6deed6e9f0c7bb8c110028d62d6359fab Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Fri, 29 Mar 2024 20:27:47 +0100 Subject: [PATCH] fix(cli config): create folder for config --- registry/Cargo.toml | 2 +- src/cli/mod.rs | 6 ++++-- src/package_name.rs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/registry/Cargo.toml b/registry/Cargo.toml index c8cd6b5..4d68c15 100644 --- a/registry/Cargo.toml +++ b/registry/Cargo.toml @@ -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" \ No newline at end of file +zstd-sys = "=2.0.9" \ No newline at end of file diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 15332dd..f799f26 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -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, )?; diff --git a/src/package_name.rs b/src/package_name.rs index 76f7a81..7e49414 100644 --- a/src/package_name.rs +++ b/src/package_name.rs @@ -110,7 +110,7 @@ pub enum EscapedPackageNameError { Invalid(String), /// The package name is invalid - #[error("invalid package name")] + #[error(transparent)] InvalidName(#[from] E), } @@ -122,7 +122,7 @@ pub enum FromStrPackageNameParseError { Invalid(String), /// The package name is invalid - #[error("invalid name part")] + #[error(transparent)] InvalidPart(#[from] E), }