mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-31 07:23:15 +08:00
fix the content_file import
This commit is contained in:
parent
dd506e5d87
commit
d481669b7e
@ -17,6 +17,7 @@ use meilisearch_types::tasks::{Kind, KindWithContent, Status, Task};
|
|||||||
use meilisearch_types::InstanceUid;
|
use meilisearch_types::InstanceUid;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::str::FromStr;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
use file_store::FileStore;
|
use file_store::FileStore;
|
||||||
@ -406,19 +407,24 @@ impl IndexScheduler {
|
|||||||
// Currently we don't need to access the tasks queue while loading a dump thus I can block everything.
|
// Currently we don't need to access the tasks queue while loading a dump thus I can block everything.
|
||||||
let mut wtxn = self.env.write_txn()?;
|
let mut wtxn = self.env.write_txn()?;
|
||||||
|
|
||||||
let content_uuid = if let Some(content_file) = content_file {
|
let content_uuid = match content_file {
|
||||||
|
Some(content_file) if task.status == Status::Enqueued => {
|
||||||
let (uuid, mut file) = self.create_update_file()?;
|
let (uuid, mut file) = self.create_update_file()?;
|
||||||
let mut builder = DocumentsBatchBuilder::new(file.as_file_mut());
|
let mut builder = DocumentsBatchBuilder::new(file.as_file_mut());
|
||||||
for doc in content_file {
|
for doc in content_file {
|
||||||
builder.append_json_object(&doc?)?;
|
builder.append_json_object(&doc?)?;
|
||||||
}
|
}
|
||||||
builder.into_inner()?;
|
builder.into_inner()?;
|
||||||
|
|
||||||
file.persist()?;
|
file.persist()?;
|
||||||
|
|
||||||
Some(uuid)
|
Some(uuid)
|
||||||
} else {
|
}
|
||||||
None
|
// If the task isn't `Enqueued` then just generate a recognisable `Uuid`
|
||||||
|
// in case we try to open it later.
|
||||||
|
_ if task.status != Status::Enqueued => {
|
||||||
|
Some(Uuid::from_str("00112233-4455-6677-8899-aabbccddeeff").unwrap())
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let task = Task {
|
let task = Task {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user