diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs index f21588aa..85d16456 100644 --- a/src/backup/datastore.rs +++ b/src/backup/datastore.rs @@ -13,6 +13,7 @@ use crate::config::datastore; use super::chunk_store::*; use super::fixed_index::*; use super::dynamic_index::*; +use super::index::*; use chrono::{Utc, TimeZone}; @@ -134,6 +135,20 @@ impl DataStore { Ok(index) } + pub fn open_index

(&self, filename: P) -> Result, Error> + where + P: AsRef, + { + let filename = filename.as_ref(); + let out: Box = + match filename.extension().and_then(|ext| ext.to_str()) { + Some("didx") => Box::new(self.open_dynamic_reader(filename)?), + Some("fidx") => Box::new(self.open_fixed_reader(filename)?), + _ => bail!("cannot open index file of unknown type: {:?}", filename), + }; + Ok(out) + } + pub fn base_path(&self) -> PathBuf { self.chunk_store.base_path() }