Skip to content

Commit

Permalink
delete LfsFallbackRemoteStore
Browse files Browse the repository at this point in the history
Summary:
Grepping shows it's not longer used anywhere. It's safe to delete altogether. This will also fix 2 warnings:

```
warning: associated function `new` is never used
    --> fbcode/eden/scm/lib/revisionstore/src/lfs.rs:1993:12
     |
1992 | impl LfsFallbackRemoteStore {
     | --------------------------- associated function in this implementation
1993 |     pub fn new(wrapped_store: Arc<dyn RemoteDataStore>) -> Arc<dyn RemoteDataStore> {
     |            ^^^

warning: associated function `new` is never used
    --> fbcode/eden/scm/lib/revisionstore/src/lfs.rs:1993:12
     |
1992 | impl LfsFallbackRemoteStore {
     | --------------------------- associated function in this implementation
1993 |     pub fn new(wrapped_store: Arc<dyn RemoteDataStore>) -> Arc<dyn RemoteDataStore> {
     |            ^^^
     |
     = note: `#[warn(dead_code)]` on by default

```

Reviewed By: quark-zju

Differential Revision: D65218832

fbshipit-source-id: 55825e13e9e1d3367f2da58c15e86768462b41e9
  • Loading branch information
MichaelCuevas authored and facebook-github-bot committed Oct 30, 2024
1 parent 2e820dd commit 51e3049
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions eden/scm/lib/revisionstore/src/lfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1980,78 +1980,6 @@ impl LocalStore for LfsRemoteStore {
}
}

/// Wraps another remote store to retry fetching content-keys from their HgId keys.
///
/// If for any reason, the LFS server is turned off, we will end up in here for blobs where we have
/// the pointer locally, but not the blob. In this case, we want the code to fallback to fetching
/// the blob with the regular non-LFS protocol, hence this stores merely translates
/// `StoreKey::Content` onto `StoreKey::HgId` before asking the non-LFS remote store to fetch data
/// for these.
pub struct LfsFallbackRemoteStore(Arc<dyn RemoteDataStore>);

impl LfsFallbackRemoteStore {
pub fn new(wrapped_store: Arc<dyn RemoteDataStore>) -> Arc<dyn RemoteDataStore> {
Arc::new(Self(wrapped_store))
}
}

impl RemoteDataStore for LfsFallbackRemoteStore {
fn prefetch(&self, keys: &[StoreKey]) -> Result<Vec<StoreKey>> {
let mut not_found = Vec::new();
let not_prefetched = self.0.prefetch(
&keys
.iter()
.filter_map(|key| match key {
StoreKey::HgId(_) => {
not_found.push(key.clone());
None
}
StoreKey::Content(_, hgid) => match hgid {
None => {
not_found.push(key.clone());
None
}
Some(hgid) => Some(StoreKey::hgid(hgid.clone())),
},
})
.collect::<Vec<_>>(),
)?;

not_found.extend(not_prefetched);
Ok(not_found)
}

fn upload(&self, keys: &[StoreKey]) -> Result<Vec<StoreKey>> {
Ok(keys.to_vec())
}
}

impl HgIdDataStore for LfsFallbackRemoteStore {
fn get(&self, key: StoreKey) -> Result<StoreResult<Vec<u8>>> {
match self.prefetch(&[key.clone()]) {
Ok(_) => self.0.get(key),
Err(_) => Ok(StoreResult::NotFound(key)),
}
}

fn get_meta(&self, key: StoreKey) -> Result<StoreResult<Metadata>> {
match self.prefetch(&[key.clone()]) {
Ok(_) => self.0.get_meta(key),
Err(_) => Ok(StoreResult::NotFound(key)),
}
}

fn refresh(&self) -> Result<()> {
self.0.refresh()
}
}

impl LocalStore for LfsFallbackRemoteStore {
fn get_missing(&self, keys: &[StoreKey]) -> Result<Vec<StoreKey>> {
self.0.get_missing(keys)
}
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
enum RetryStrategy {
RetryError,
Expand Down

0 comments on commit 51e3049

Please sign in to comment.