Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hard_link_hash #82

Merged
merged 4 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,16 @@ where
read::reflink_async(cache.as_ref(), sri, to.as_ref()).await
}

/// Hard links a cache entry by hash to a specified location.
#[cfg(any(feature = "async-std", feature = "tokio"))]
pub async fn hard_link_hash<P, Q>(cache: P, sri: &Integrity, to: Q) -> Result<()>
where
P: AsRef<Path>,
Q: AsRef<Path>,
{
read::hard_link_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<P, K, Q>(cache: P, key: K, to: Q) -> Result<()>
Expand All @@ -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()))
}
Expand Down
Loading