diff --git a/yazi-cli/src/package/delete.rs b/yazi-cli/src/package/delete.rs index ec35eb5f..fcf695e9 100644 --- a/yazi-cli/src/package/delete.rs +++ b/yazi-cli/src/package/delete.rs @@ -9,10 +9,9 @@ impl Dependency { pub(super) async fn delete(&self) -> Result<()> { self.header("Deleting package `{name}`")?; - let path = self.deployed_directory(); - - if must_exists(&path).await { - fs::remove_dir_all(&path).await?; + let dir = self.target(); + if must_exists(&dir).await { + fs::remove_dir_all(&dir).await?; } else { bail!( "The package.toml file states that `{}` exists, but the directory was not found. The entry will be removed from package.toml.", diff --git a/yazi-cli/src/package/dependency.rs b/yazi-cli/src/package/dependency.rs index 76f4f72a..de5f292c 100644 --- a/yazi-cli/src/package/dependency.rs +++ b/yazi-cli/src/package/dependency.rs @@ -20,15 +20,18 @@ pub(crate) struct Dependency { } impl Dependency { - #[inline] pub(super) fn local(&self) -> PathBuf { Xdg::state_dir() .join("packages") .join(format!("{:x}", XxHash3_128::oneshot(self.remote().as_bytes()))) } - #[inline] - pub(super) fn deployed_directory(&self) -> PathBuf { + pub(super) fn remote(&self) -> String { + // Support more Git hosting services in the future + format!("https://github.com/{}.git", self.parent) + } + + pub(super) fn target(&self) -> PathBuf { if self.is_flavor { Xdg::config_dir().join(format!("flavors/{}", self.name)) } else { @@ -36,12 +39,6 @@ impl Dependency { } } - #[inline] - pub(super) fn remote(&self) -> String { - // Support more Git hosting services in the future - format!("https://github.com/{}.git", self.parent) - } - pub(super) fn header(&self, s: &str) -> Result<()> { use crossterm::style::{Attribute, Print, SetAttributes}; diff --git a/yazi-cli/src/package/deploy.rs b/yazi-cli/src/package/deploy.rs index b9a8da5c..b630b2d2 100644 --- a/yazi-cli/src/package/deploy.rs +++ b/yazi-cli/src/package/deploy.rs @@ -14,8 +14,7 @@ impl Dependency { self.header("Deploying package `{name}`")?; self.is_flavor = maybe_exists(&from.join("flavor.toml")).await; - let to = self.deployed_directory(); - + let to = self.target(); if maybe_exists(&to).await && self.hash != self.hash().await? { bail!( "The user has modified the contents of the `{}` package. For safety, the operation has been aborted. diff --git a/yazi-cli/src/package/hash.rs b/yazi-cli/src/package/hash.rs index 3ccc0da5..761b72b2 100644 --- a/yazi-cli/src/package/hash.rs +++ b/yazi-cli/src/package/hash.rs @@ -7,8 +7,7 @@ use super::Dependency; impl Dependency { pub(crate) async fn hash(&self) -> Result { - let dir = self.deployed_directory(); - + let dir = self.target(); let files = if self.is_flavor { &[ "LICENSE",