mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Create the index only if the task has the rights to do so
This commit is contained in:
parent
068a4b2884
commit
123f47dbc4
@ -234,8 +234,8 @@ impl IndexScheduler {
|
|||||||
Batch::IndexOperation(IndexOperation::Settings {
|
Batch::IndexOperation(IndexOperation::Settings {
|
||||||
index_uid,
|
index_uid,
|
||||||
settings,
|
settings,
|
||||||
allow_index_creation,
|
|
||||||
tasks,
|
tasks,
|
||||||
|
..
|
||||||
}) => (index_uid, settings, tasks),
|
}) => (index_uid, settings, tasks),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
@ -422,6 +422,7 @@ impl IndexScheduler {
|
|||||||
Batch::Snapshot(_) => todo!(),
|
Batch::Snapshot(_) => todo!(),
|
||||||
Batch::Dump(_) => todo!(),
|
Batch::Dump(_) => todo!(),
|
||||||
Batch::IndexOperation(operation) => {
|
Batch::IndexOperation(operation) => {
|
||||||
|
#[rustfmt::skip]
|
||||||
let index = match operation {
|
let index = match operation {
|
||||||
IndexOperation::DocumentDeletion { ref index_uid, .. }
|
IndexOperation::DocumentDeletion { ref index_uid, .. }
|
||||||
| IndexOperation::DocumentClear { ref index_uid, .. } => {
|
| IndexOperation::DocumentClear { ref index_uid, .. } => {
|
||||||
@ -429,17 +430,20 @@ impl IndexScheduler {
|
|||||||
let rtxn = self.env.read_txn()?;
|
let rtxn = self.env.read_txn()?;
|
||||||
self.index_mapper.index(&rtxn, index_uid)?
|
self.index_mapper.index(&rtxn, index_uid)?
|
||||||
}
|
}
|
||||||
IndexOperation::DocumentImport { ref index_uid, .. }
|
IndexOperation::DocumentImport { ref index_uid, allow_index_creation, .. }
|
||||||
| IndexOperation::Settings { ref index_uid, .. }
|
| IndexOperation::Settings { ref index_uid, allow_index_creation, .. }
|
||||||
| IndexOperation::DocumentClearAndSetting { ref index_uid, .. }
|
| IndexOperation::DocumentClearAndSetting { ref index_uid, allow_index_creation, .. }
|
||||||
| IndexOperation::SettingsAndDocumentImport { ref index_uid, .. } => {
|
| IndexOperation::SettingsAndDocumentImport {ref index_uid, allow_index_creation, .. } => {
|
||||||
// TODO check if the user was allowed to create an index.
|
if allow_index_creation {
|
||||||
|
// create the index if it doesn't already exist
|
||||||
// create the index if it doesn't already exist
|
let mut wtxn = self.env.write_txn()?;
|
||||||
let mut wtxn = self.env.write_txn()?;
|
let index = self.index_mapper.create_index(&mut wtxn, index_uid)?;
|
||||||
let index = self.index_mapper.create_index(&mut wtxn, index_uid)?;
|
wtxn.commit()?;
|
||||||
wtxn.commit()?;
|
index
|
||||||
index
|
} else {
|
||||||
|
let rtxn = self.env.read_txn()?;
|
||||||
|
self.index_mapper.index(&rtxn, index_uid)?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -553,7 +557,7 @@ impl IndexScheduler {
|
|||||||
index_uid: _,
|
index_uid: _,
|
||||||
primary_key,
|
primary_key,
|
||||||
method,
|
method,
|
||||||
allow_index_creation,
|
allow_index_creation: _,
|
||||||
documents_counts,
|
documents_counts,
|
||||||
content_files,
|
content_files,
|
||||||
mut tasks,
|
mut tasks,
|
||||||
@ -661,7 +665,7 @@ impl IndexScheduler {
|
|||||||
IndexOperation::Settings {
|
IndexOperation::Settings {
|
||||||
index_uid: _,
|
index_uid: _,
|
||||||
settings,
|
settings,
|
||||||
allow_index_creation,
|
allow_index_creation: _,
|
||||||
mut tasks,
|
mut tasks,
|
||||||
} => {
|
} => {
|
||||||
let indexer_config = self.index_mapper.indexer_config();
|
let indexer_config = self.index_mapper.indexer_config();
|
||||||
|
Loading…
Reference in New Issue
Block a user