From 91de46eaf549d8450bd7aac8bc2e2a5167887b2e Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Thu, 13 Jun 2024 18:17:51 +0800 Subject: [PATCH] add hard_link_hash --- src/get.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/get.rs b/src/get.rs index 374a154..51ae5c0 100644 --- a/src/get.rs +++ b/src/get.rs @@ -402,6 +402,16 @@ where read::reflink_async(cache.as_ref(), sri, to.as_ref()).await } +/// Hard links a cache entry by key to a specified location. +#[cfg(any(feature = "async-std", feature = "tokio"))] +pub async fn hard_link_hash(cache: P, key: &Integrity, to: Q) -> Result<()> +where + P: AsRef, + Q: AsRef, +{ + read::hard_link_async(cache, &entry.integrity, to).await +} + /// Hard links a cache entry by key to a specified location. #[cfg(any(feature = "async-std", feature = "tokio"))] pub async fn hard_link(cache: P, key: K, to: Q) -> Result<()> @@ -412,7 +422,7 @@ where { async fn inner(cache: &Path, key: &str, to: &Path) -> Result<()> { if let Some(entry) = index::find(cache, key)? { - read::hard_link_async(cache, &entry.integrity, to).await + hard_link_hash(cache, &entry.integrity, to).await } else { Err(Error::EntryNotFound(cache.to_path_buf(), key.into())) }