Skip to content

Commit 9d76c6d

Browse files
Liubov Dmitrievafacebook-github-bot
authored andcommitted
add a new fetch_single_local_direct method
Summary: add a new fetch_single_local_direct method Reviewed By: quark-zju Differential Revision: D72165005 fbshipit-source-id: 61e9f51f57267ee25f53da0805880e546b221000
1 parent 0215524 commit 9d76c6d

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

eden/scm/lib/cas-client/re-cas-common/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ macro_rules! re_client {
8989

9090
#[$crate::async_trait]
9191
impl $crate::CasClient for $struct {
92+
fn fetch_single_local_direct(
93+
&self,
94+
_fctx: $crate::FetchContext,
95+
digest: &$crate::CasDigest,
96+
) -> Result<Option<ScmBlob>> {
97+
return Ok(None);
98+
}
9299
async fn fetch<'a>(
93100
&'a self,
94101
_fctx: $crate::FetchContext,

eden/scm/lib/cas-client/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ pub fn new(config: Arc<dyn Config>) -> anyhow::Result<Option<Arc<dyn CasClient>>
120120
#[async_trait::async_trait]
121121
#[auto_impl::auto_impl(&, Box, Arc)]
122122
pub trait CasClient: Sync + Send {
123+
/// Fetch a single blob from local CAS caches.
124+
fn fetch_single_local_direct(
125+
&self,
126+
_fctx: FetchContext,
127+
digest: &CasDigest,
128+
) -> anyhow::Result<Option<ScmBlob>>;
123129
/// Fetch blobs from CAS.
124130
async fn fetch<'a>(
125131
&'a self,

eden/scm/lib/eagerepo/src/trait_impls.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ impl ReadRootTreeIds for EagerRepoStore {
182182

183183
#[async_trait::async_trait]
184184
impl CasClient for EagerRepoStore {
185+
/// Fetch a single blob from local CAS caches.
186+
fn fetch_single_local_direct(
187+
&self,
188+
_fctx: FetchContext,
189+
digest: &CasDigest,
190+
) -> anyhow::Result<Option<ScmBlob>> {
191+
self.get_cas_blob(*digest)
192+
.map_err(Into::into)
193+
.map(|data| data.map(ScmBlob::Bytes))
194+
}
185195
async fn fetch<'a>(
186196
&'a self,
187197
_fctx: FetchContext,

0 commit comments

Comments
 (0)