mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-10 23:18:55 +01:00
fix dump import
This commit is contained in:
parent
1cb64caae4
commit
39c16c0fe4
@ -12,7 +12,7 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use super::UpdateStore;
|
use super::UpdateStore;
|
||||||
use super::{codec::UpdateKeyCodec, State};
|
use super::{codec::UpdateKeyCodec, State};
|
||||||
use crate::index_controller::{index_actor::IndexActorHandle, UpdateStatus};
|
use crate::index_controller::{Enqueued, UpdateStatus, index_actor::IndexActorHandle, update_actor::store::update_uuid_to_file_path};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct UpdateEntry {
|
struct UpdateEntry {
|
||||||
@ -69,7 +69,7 @@ impl UpdateStore {
|
|||||||
txn: &RoTxn,
|
txn: &RoTxn,
|
||||||
uuids: &HashSet<Uuid>,
|
uuids: &HashSet<Uuid>,
|
||||||
mut file: &mut File,
|
mut file: &mut File,
|
||||||
dst_update_files: impl AsRef<Path>,
|
dst_path: impl AsRef<Path>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let pendings = self.pending_queue.iter(txn)?.lazily_decode_data();
|
let pendings = self.pending_queue.iter(txn)?.lazily_decode_data();
|
||||||
|
|
||||||
@ -79,10 +79,9 @@ impl UpdateStore {
|
|||||||
let update = data.decode()?;
|
let update = data.decode()?;
|
||||||
|
|
||||||
if let Some(ref update_uuid) = update.content {
|
if let Some(ref update_uuid) = update.content {
|
||||||
let src = dbg!(super::update_uuid_to_file_path(&self.path, *update_uuid));
|
let src = super::update_uuid_to_file_path(&self.path, *update_uuid);
|
||||||
let dst = dbg!(super::update_uuid_to_file_path(&dst_update_files, *update_uuid));
|
let dst = super::update_uuid_to_file_path(&dst_path, *update_uuid);
|
||||||
assert!(src.exists());
|
std::fs::copy(src, dst)?;
|
||||||
dbg!(std::fs::copy(src, dst))?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("copied files");
|
println!("copied files");
|
||||||
@ -144,6 +143,8 @@ impl UpdateStore {
|
|||||||
let update_data = File::open(&src_update_path.join("data.jsonl"))?;
|
let update_data = File::open(&src_update_path.join("data.jsonl"))?;
|
||||||
let mut update_data = BufReader::new(update_data);
|
let mut update_data = BufReader::new(update_data);
|
||||||
|
|
||||||
|
std::fs::create_dir_all(dst_update_path.join("update_files/"))?;
|
||||||
|
|
||||||
let mut wtxn = store.env.write_txn()?;
|
let mut wtxn = store.env.write_txn()?;
|
||||||
let mut line = String::new();
|
let mut line = String::new();
|
||||||
loop {
|
loop {
|
||||||
@ -151,7 +152,14 @@ impl UpdateStore {
|
|||||||
Ok(0) => break,
|
Ok(0) => break,
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let UpdateEntry { uuid, update } = serde_json::from_str(&line)?;
|
let UpdateEntry { uuid, update } = serde_json::from_str(&line)?;
|
||||||
store.register_raw_updates(&mut wtxn, update, uuid)?;
|
store.register_raw_updates(&mut wtxn, &update, uuid)?;
|
||||||
|
|
||||||
|
// Copy ascociated update path if it exists
|
||||||
|
if let UpdateStatus::Enqueued(Enqueued { content: Some(uuid), .. }) = update {
|
||||||
|
let src = update_uuid_to_file_path(&src_update_path, uuid);
|
||||||
|
let dst = update_uuid_to_file_path(&dst_update_path, uuid);
|
||||||
|
std::fs::copy(src, dst)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => break,
|
_ => break,
|
||||||
}
|
}
|
||||||
@ -159,10 +167,6 @@ impl UpdateStore {
|
|||||||
line.clear();
|
line.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
let dst_update_files_path = dst_update_path.join("update_files/");
|
|
||||||
let src_update_files_path = src_update_path.join("update_files/");
|
|
||||||
std::fs::copy(src_update_files_path, dst_update_files_path)?;
|
|
||||||
|
|
||||||
wtxn.commit()?;
|
wtxn.commit()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -244,7 +244,7 @@ impl UpdateStore {
|
|||||||
pub fn register_raw_updates(
|
pub fn register_raw_updates(
|
||||||
&self,
|
&self,
|
||||||
wtxn: &mut heed::RwTxn,
|
wtxn: &mut heed::RwTxn,
|
||||||
update: UpdateStatus,
|
update: &UpdateStatus,
|
||||||
index_uuid: Uuid,
|
index_uuid: Uuid,
|
||||||
) -> heed::Result<()> {
|
) -> heed::Result<()> {
|
||||||
match update {
|
match update {
|
||||||
|
Loading…
Reference in New Issue
Block a user