From 89e127e4f49642b35bb4a38250242e9803ad426e Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 25 Oct 2022 14:35:10 +0200 Subject: [PATCH] Declare the auth path in the index scheduler --- index-scheduler/src/batch.rs | 6 ++---- index-scheduler/src/insta_snapshot.rs | 1 + index-scheduler/src/lib.rs | 8 ++++++++ meilisearch-http/src/lib.rs | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/index-scheduler/src/batch.rs b/index-scheduler/src/batch.rs index 739b342a7..39ab862ba 100644 --- a/index-scheduler/src/batch.rs +++ b/index-scheduler/src/batch.rs @@ -560,7 +560,7 @@ impl IndexScheduler { // 1. Snapshot the version file. // TODO where can I find the path of this file and do we create it anyway? // let dst = temp_snapshot_dir.path().join(VERSION_FILE_NAME); - // let src = self.src_path.join(VERSION_FILE_NAME); + // let src = self.base_path.join(VERSION_FILE_NAME); // fs::copy(src, dst)?; // TODO what is a meta-env in the previous version of the scheduler? @@ -618,9 +618,7 @@ impl IndexScheduler { // 4. Snapshot the auth LMDB env let dst = temp_snapshot_dir.path().join("auth").join("data.mdb"); fs::create_dir_all(&dst)?; - // TODO find a better way to get the auth database path - let auth_path = self.env.path().join("..").join("auth"); - let auth = milli::heed::EnvOpenOptions::new().open(auth_path)?; + let auth = milli::heed::EnvOpenOptions::new().open(&self.auth_path)?; auth.copy_to_path(dst, CompactionOption::Enabled)?; todo!("tar-gz and append .snapshot at the end of the file"); diff --git a/index-scheduler/src/insta_snapshot.rs b/index-scheduler/src/insta_snapshot.rs index 8f0b6129f..6e5dd187a 100644 --- a/index-scheduler/src/insta_snapshot.rs +++ b/index-scheduler/src/insta_snapshot.rs @@ -27,6 +27,7 @@ pub fn snapshot_index_scheduler(scheduler: &IndexScheduler) -> String { wake_up: _, dumps_path: _, snapshots_path: _, + auth_path: _, test_breakpoint_sdr: _, planned_failures: _, run_loop_iteration: _, diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 15e57aacb..cdb2e09e8 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -245,6 +245,9 @@ pub struct IndexScheduler { /// The path used to create the snapshots. pub(crate) snapshots_path: PathBuf, + /// The path to the folder containing the auth LMDB env. + pub(crate) auth_path: PathBuf, + // ================= test // The next entry is dedicated to the tests. /// Provide a way to set a breakpoint in multiple part of the scheduler. @@ -282,6 +285,7 @@ impl IndexScheduler { autobatching_enabled: self.autobatching_enabled, snapshots_path: self.snapshots_path.clone(), dumps_path: self.dumps_path.clone(), + auth_path: self.auth_path.clone(), #[cfg(test)] test_breakpoint_sdr: self.test_breakpoint_sdr.clone(), #[cfg(test)] @@ -306,9 +310,11 @@ pub enum Breakpoint { } impl IndexScheduler { + // TODO create a struct of options with a documented field for each required option instead /// Create an index scheduler and start its run loop. /// /// ## Arguments + /// - `auth_path`: the path to the folder containing the auth LMDB env /// - `tasks_path`: the path to the folder containing the task databases /// - `update_file_path`: the path to the file store containing the files associated to the tasks /// - `indexes_path`: the path to the folder containing meilisearch's indexes @@ -320,6 +326,7 @@ impl IndexScheduler { /// together, to process multiple tasks at once. #[allow(clippy::too_many_arguments)] pub fn new( + auth_path: PathBuf, tasks_path: PathBuf, update_file_path: PathBuf, indexes_path: PathBuf, @@ -363,6 +370,7 @@ impl IndexScheduler { autobatching_enabled, dumps_path, snapshots_path, + auth_path, #[cfg(test)] test_breakpoint_sdr, diff --git a/meilisearch-http/src/lib.rs b/meilisearch-http/src/lib.rs index 656e7460a..6ab205385 100644 --- a/meilisearch-http/src/lib.rs +++ b/meilisearch-http/src/lib.rs @@ -110,6 +110,8 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(IndexScheduler, AuthContr let auth_controller_builder = || AuthController::new(&opt.db_path, &opt.master_key); let index_scheduler_builder = || { IndexScheduler::new( + // TODO find a better way to have the path of the auth store + opt.db_path.join("auth"), opt.db_path.join("tasks"), opt.db_path.join("update_files"), opt.db_path.join("indexes"),