Skip to content

Commit ab5f1c9

Browse files
authored
feat(link): add hard_link_hash (#82)
Fixes: #80
1 parent 3a71247 commit ab5f1c9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/get.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,16 @@ where
402402
read::reflink_async(cache.as_ref(), sri, to.as_ref()).await
403403
}
404404

405+
/// Hard links a cache entry by hash to a specified location.
406+
#[cfg(any(feature = "async-std", feature = "tokio"))]
407+
pub async fn hard_link_hash<P, Q>(cache: P, sri: &Integrity, to: Q) -> Result<()>
408+
where
409+
P: AsRef<Path>,
410+
Q: AsRef<Path>,
411+
{
412+
read::hard_link_async(cache.as_ref(), sri, to.as_ref()).await
413+
}
414+
405415
/// Hard links a cache entry by key to a specified location.
406416
#[cfg(any(feature = "async-std", feature = "tokio"))]
407417
pub async fn hard_link<P, K, Q>(cache: P, key: K, to: Q) -> Result<()>
@@ -412,7 +422,7 @@ where
412422
{
413423
async fn inner(cache: &Path, key: &str, to: &Path) -> Result<()> {
414424
if let Some(entry) = index::find(cache, key)? {
415-
read::hard_link_async(cache, &entry.integrity, to).await
425+
hard_link_hash(cache, &entry.integrity, to).await
416426
} else {
417427
Err(Error::EntryNotFound(cache.to_path_buf(), key.into()))
418428
}

0 commit comments

Comments
 (0)