mirror of https://github.com/zkat/cacache-rs.git
add hard_link_hash
This commit is contained in:
parent
c102c01e76
commit
91de46eaf5
12
src/get.rs
12
src/get.rs
|
|
@ -402,6 +402,16 @@ where
|
||||||
read::reflink_async(cache.as_ref(), sri, to.as_ref()).await
|
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<P, K, Q>(cache: P, key: &Integrity, to: Q) -> Result<()>
|
||||||
|
where
|
||||||
|
P: AsRef<Path>,
|
||||||
|
Q: AsRef<Path>,
|
||||||
|
{
|
||||||
|
read::hard_link_async(cache, &entry.integrity, to).await
|
||||||
|
}
|
||||||
|
|
||||||
/// Hard links a cache entry by key to a specified location.
|
/// Hard links a cache entry by key to a specified location.
|
||||||
#[cfg(any(feature = "async-std", feature = "tokio"))]
|
#[cfg(any(feature = "async-std", feature = "tokio"))]
|
||||||
pub async fn hard_link<P, K, Q>(cache: P, key: K, to: Q) -> Result<()>
|
pub async fn hard_link<P, K, Q>(cache: P, key: K, to: Q) -> Result<()>
|
||||||
|
|
@ -412,7 +422,7 @@ where
|
||||||
{
|
{
|
||||||
async fn inner(cache: &Path, key: &str, to: &Path) -> Result<()> {
|
async fn inner(cache: &Path, key: &str, to: &Path) -> Result<()> {
|
||||||
if let Some(entry) = index::find(cache, key)? {
|
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 {
|
} else {
|
||||||
Err(Error::EntryNotFound(cache.to_path_buf(), key.into()))
|
Err(Error::EntryNotFound(cache.to_path_buf(), key.into()))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue