Repository: meilisearch/meilisearch
File: meilisearch-http/src/lib.rs (Rust)

Code before:
use std::sync::{atomic::AtomicBool, Arc};
use std::time::Duration;

use crate::error::MeilisearchHttpError;
use actix_web::error::JsonPayloadError;
use analytics::Analytics;
use error::PayloadError;
use http::header::CONTENT_TYPE;
pub use option::Opt;

use actix_web::{web, HttpRequest};

use extractors::payload::PayloadConfig;
use meilisearch_auth::AuthController;
use meilisearch_lib::MeiliSearch;

pub static AUTOBATCHING_ENABLED: AtomicBool = AtomicBool::new(false);

pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<MeiliSearch> {
    let mut meilisearch = MeiliSearch::builder();

    // disable autobatching?
    AUTOBATCHING_ENABLED.store(
        opt.scheduler_options.disable_auto_batching,
        std::sync::atomic::Ordering::Relaxed,
    );

    meilisearch
        .set_max_index_size(opt.max_index_size.get_bytes() as usize)
        .set_max_task_store_size(opt.max_task_db_size.get_bytes() as usize)
        // snapshot
        .set_ignore_missing_snapshot(opt.ignore_missing_snapshot)
        .set_ignore_snapshot_if_db_exists(opt.ignore_snapshot_if_db_exists)
        .set_snapshot_interval(Duration::from_secs(opt.snapshot_interval_sec))
        .set_snapshot_dir(opt.snapshot_dir.clone())
        // dump
        .set_ignore_missing_dump(opt.ignore_missing_dump)
        .set_ignore_dump_if_db_exists(opt.ignore_dump_if_db_exists)
        .set_dump_dst(opt.dumps_dir.clone());

    if let Some(ref path) = opt.import_snapshot {
        meilisearch.set_import_snapshot(path.clone());
    }

    if let Some(ref path) = opt.import_dump {
        meilisearch.set_dump_src(path.clone());
    }

    if opt.schedule_snapshot {
        meilisearch.set_schedule_snapshot();
    }

Review comment (suggestion):
Are we sure about the names and booleans values, here. We changed the boolean but not the name of the global. @ManyTheFish 

Code after:
use std::sync::{atomic::AtomicBool, Arc};
use std::time::Duration;

use crate::error::MeilisearchHttpError;
use actix_web::error::JsonPayloadError;
use analytics::Analytics;
use error::PayloadError;
use http::header::CONTENT_TYPE;
pub use option::Opt;

use actix_web::{web, HttpRequest};

use extractors::payload::PayloadConfig;
use meilisearch_auth::AuthController;
use meilisearch_lib::MeiliSearch;

pub static AUTOBATCHING_ENABLED: AtomicBool = AtomicBool::new(false);

pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<MeiliSearch> {
    let mut meilisearch = MeiliSearch::builder();

    // disable autobatching?
    AUTOBATCHING_ENABLED.store(
        !opt.scheduler_options.disable_auto_batching,
        std::sync::atomic::Ordering::Relaxed,
    );

    meilisearch
        .set_max_index_size(opt.max_index_size.get_bytes() as usize)
        .set_max_task_store_size(opt.max_task_db_size.get_bytes() as usize)
        // snapshot
        .set_ignore_missing_snapshot(opt.ignore_missing_snapshot)
        .set_ignore_snapshot_if_db_exists(opt.ignore_snapshot_if_db_exists)
        .set_snapshot_interval(Duration::from_secs(opt.snapshot_interval_sec))
        .set_snapshot_dir(opt.snapshot_dir.clone())
        // dump
        .set_ignore_missing_dump(opt.ignore_missing_dump)
        .set_ignore_dump_if_db_exists(opt.ignore_dump_if_db_exists)
        .set_dump_dst(opt.dumps_dir.clone());

    if let Some(ref path) = opt.import_snapshot {
        meilisearch.set_import_snapshot(path.clone());
    }

    if let Some(ref path) = opt.import_dump {
        meilisearch.set_dump_src(path.clone());
    }

    if opt.schedule_snapshot {
        meilisearch.set_schedule_snapshot();
    }