mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
restore snapshots
This commit is contained in:
parent
b9d189bf12
commit
90018755c5
15 changed files with 397 additions and 317 deletions
|
@ -57,7 +57,7 @@ impl IndexStore for MapIndexStore {
|
|||
if let Some(index) = lock.get(&uuid) {
|
||||
return Ok(index.clone());
|
||||
}
|
||||
let path = self.path.join(format!("index-{}", uuid));
|
||||
let path = self.path.join(format!("{}", uuid));
|
||||
if path.exists() {
|
||||
return Err(IndexResolverError::IndexAlreadyExists);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ impl IndexStore for MapIndexStore {
|
|||
None => {
|
||||
// drop the guard here so we can perform the write after without deadlocking;
|
||||
drop(guard);
|
||||
let path = self.path.join(format!("index-{}", uuid));
|
||||
let path = self.path.join(format!("{}", uuid));
|
||||
if !path.exists() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ impl IndexStore for MapIndexStore {
|
|||
}
|
||||
|
||||
async fn delete(&self, uuid: Uuid) -> Result<Option<Index>> {
|
||||
let db_path = self.path.join(format!("index-{}", uuid));
|
||||
let db_path = self.path.join(format!("{}", uuid));
|
||||
fs::remove_dir_all(db_path).await?;
|
||||
let index = self.index_store.write().await.remove(&uuid);
|
||||
Ok(index)
|
||||
|
|
|
@ -45,10 +45,18 @@ where U: UuidStore,
|
|||
|
||||
pub async fn get_size(&self) -> Result<u64> {
|
||||
todo!()
|
||||
//Ok(self.index_store.get_size()? + self.index_uuid_store.get_size().await?)
|
||||
}
|
||||
|
||||
pub async fn perform_snapshot(&self, _path: impl AsRef<Path>) -> Result<()> {
|
||||
todo!()
|
||||
pub async fn snapshot(&self, path: impl AsRef<Path>) -> Result<Vec<Index>> {
|
||||
let uuids = self.index_uuid_store.snapshot(path.as_ref().to_owned()).await?;
|
||||
let mut indexes = Vec::new();
|
||||
|
||||
for uuid in uuids {
|
||||
indexes.push(self.get_index_by_uuid(uuid).await?);
|
||||
}
|
||||
|
||||
Ok(indexes)
|
||||
}
|
||||
|
||||
pub async fn create_index(&self, uid: String, primary_key: Option<String>) -> Result<(Uuid, Index)> {
|
||||
|
|
|
@ -46,8 +46,9 @@ impl HeedUuidStore {
|
|||
create_dir_all(&path)?;
|
||||
let mut options = EnvOpenOptions::new();
|
||||
options.map_size(UUID_STORE_SIZE); // 1GB
|
||||
options.max_dbs(1);
|
||||
let env = options.open(path)?;
|
||||
let db = env.create_database(None)?;
|
||||
let db = env.create_database(Some("uuids"))?;
|
||||
Ok(Self { env, db })
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue