treemanifest: flush shared stores when flushing local stores

Summary:
The Rust contentstore has no way to flush the shared stores, except
when the object is destructed. In treemanifest, the lifetime of the shared store
seems to be different from with files and we're not seeing them flushes
appropriately during certain commands. Let's make the flush api also flush the
shared stores.

Reviewed By: quark-zju

Differential Revision: D23662976

fbshipit-source-id: a542c3e45d5b489fcb5faf2726854cb49df16f4c
This commit is contained in:
Durham Goode 2020-09-17 14:25:27 -07:00 committed by Facebook GitHub Bot
parent 84f72950ad
commit f68177a983
4 changed files with 12 additions and 0 deletions

View File

@ -165,6 +165,11 @@ class unioncontentstore(object):
store.prefetch(keys) store.prefetch(keys)
break break
def flush(self):
for store in self.stores:
if util.safehasattr(store, "flush"):
store.flush()
class manifestrevlogstore(object): class manifestrevlogstore(object):
def __init__(self, repo): def __init__(self, repo):

View File

@ -48,3 +48,8 @@ class unionmetadatastore(object):
def removestore(self, store): def removestore(self, store):
self.stores.remove(store) self.stores.remove(store)
def flush(self):
for store in self.stores:
if util.safehasattr(store, "flush"):
store.flush()

View File

@ -186,6 +186,7 @@ impl HgIdMutableDeltaStore for ContentStore {
/// Commit the data written to the local store. /// Commit the data written to the local store.
fn flush(&self) -> Result<Option<Vec<PathBuf>>> { fn flush(&self) -> Result<Option<Vec<PathBuf>>> {
self.shared_mutabledatastore.as_ref().flush()?;
self.local_mutabledatastore self.local_mutabledatastore
.as_ref() .as_ref()
.ok_or_else(|| format_err!("flushing a non-local ContentStore is not allowed"))? .ok_or_else(|| format_err!("flushing a non-local ContentStore is not allowed"))?

View File

@ -125,6 +125,7 @@ impl HgIdMutableHistoryStore for MetadataStore {
} }
fn flush(&self) -> Result<Option<Vec<PathBuf>>> { fn flush(&self) -> Result<Option<Vec<PathBuf>>> {
self.shared_mutablehistorystore.as_ref().flush()?;
self.local_mutablehistorystore self.local_mutablehistorystore
.as_ref() .as_ref()
.ok_or_else(|| format_err!("flushing a non-local MetadataStore is not allowed"))? .ok_or_else(|| format_err!("flushing a non-local MetadataStore is not allowed"))?