mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 04:17:10 +02:00
Keep persisting tmp files in database directory and put non-persisting tmp files in default tmp dir
This commit is contained in:
parent
79817bd465
commit
b4038597ba
7 changed files with 10 additions and 35 deletions
|
@ -8,7 +8,6 @@ pub mod analytics;
|
|||
pub mod helpers;
|
||||
pub mod option;
|
||||
pub mod routes;
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::error::MeilisearchHttpError;
|
||||
|
@ -75,27 +74,6 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<MeiliSearch> {
|
|||
meilisearch.build(opt.db_path.clone(), opt.indexer_options.clone())
|
||||
}
|
||||
|
||||
/// Cleans and setup the temporary file folder in the database directory. This must be done after
|
||||
/// the meilisearch instance has been created, to not interfere with the snapshot and dump loading.
|
||||
pub fn setup_temp_dir(db_path: impl AsRef<Path>) -> anyhow::Result<()> {
|
||||
// Set the tempfile directory in the current db path, to avoid cross device references. Also
|
||||
// remove the previous outstanding files found there
|
||||
//
|
||||
// TODO: if two processes open the same db, one might delete the other tmpdir. Need to make
|
||||
// sure that no one is using it before deleting it.
|
||||
let temp_path = db_path.as_ref().join("tmp");
|
||||
// Ignore error if tempdir doesn't exist
|
||||
let _ = std::fs::remove_dir_all(&temp_path);
|
||||
std::fs::create_dir_all(&temp_path)?;
|
||||
if cfg!(windows) {
|
||||
std::env::set_var("TMP", temp_path);
|
||||
} else {
|
||||
std::env::set_var("TMPDIR", temp_path);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn configure_data(config: &mut web::ServiceConfig, data: MeiliSearch, opt: &Opt) {
|
||||
let http_payload_size_limit = opt.http_payload_size_limit.get_bytes() as usize;
|
||||
config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue