mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +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
|
@ -43,8 +43,9 @@ pub fn load_dump(
|
|||
patch_settings(settings_path)?;
|
||||
}
|
||||
|
||||
let update_path = src.as_ref().join("updates/data.jsonl");
|
||||
patch_updates(update_path)?;
|
||||
let update_dir = src.as_ref().join("updates");
|
||||
let update_path = update_dir.join("data.jsonl");
|
||||
patch_updates(update_dir, update_path)?;
|
||||
|
||||
v3::load_dump(
|
||||
meta,
|
||||
|
@ -79,8 +80,8 @@ fn patch_settings(path: impl AsRef<Path>) -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn patch_updates(path: impl AsRef<Path>) -> anyhow::Result<()> {
|
||||
let mut output_update_file = NamedTempFile::new()?;
|
||||
fn patch_updates(dir: impl AsRef<Path>, path: impl AsRef<Path>) -> anyhow::Result<()> {
|
||||
let mut output_update_file = NamedTempFile::new_in(&dir)?;
|
||||
let update_file = File::open(&path)?;
|
||||
|
||||
let stream = Deserializer::from_reader(update_file).into_iter::<compat::UpdateEntry>();
|
||||
|
|
|
@ -253,7 +253,7 @@ where
|
|||
UpdateMsg::dump(&self.update_sender, uuids, temp_dump_path.clone()).await?;
|
||||
|
||||
let dump_path = tokio::task::spawn_blocking(move || -> Result<PathBuf> {
|
||||
let temp_dump_file = tempfile::NamedTempFile::new()?;
|
||||
let temp_dump_file = tempfile::NamedTempFile::new_in(&self.path)?;
|
||||
to_tar_gz(temp_dump_path, temp_dump_file.path())
|
||||
.map_err(|e| DumpActorError::Internal(e.into()))?;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ where
|
|||
.snapshot_path
|
||||
.join(format!("{}.snapshot", self.db_name));
|
||||
let snapshot_path = spawn_blocking(move || -> anyhow::Result<PathBuf> {
|
||||
let temp_snapshot_file = tempfile::NamedTempFile::new()?;
|
||||
let temp_snapshot_file = tempfile::NamedTempFile::new_in(&snapshot_dir)?;
|
||||
let temp_snapshot_file_path = temp_snapshot_file.path().to_owned();
|
||||
crate::compression::to_tar_gz(temp_snapshot_path, temp_snapshot_file_path)?;
|
||||
temp_snapshot_file.persist(&snapshot_path)?;
|
||||
|
|
|
@ -107,7 +107,7 @@ impl UpdateFileStore {
|
|||
///
|
||||
/// A call to `persist` is needed to persist the file in the database.
|
||||
pub fn new_update(&self) -> Result<(Uuid, UpdateFile)> {
|
||||
let file = NamedTempFile::new()?;
|
||||
let file = NamedTempFile::new_in(&self.path)?;
|
||||
let uuid = Uuid::new_v4();
|
||||
let path = self.path.join(uuid.to_string());
|
||||
let update_file = UpdateFile { file, path };
|
||||
|
@ -141,7 +141,7 @@ impl UpdateFileStore {
|
|||
dst.push(&uuid_string);
|
||||
|
||||
let update_file = File::open(update_file_path)?;
|
||||
let mut dst_file = NamedTempFile::new()?;
|
||||
let mut dst_file = NamedTempFile::new_in(&dump_path)?;
|
||||
let mut document_reader = DocumentBatchReader::from_reader(update_file)?;
|
||||
|
||||
let mut document_buffer = Map::new();
|
||||
|
|
|
@ -52,7 +52,7 @@ impl UpdateStore {
|
|||
uuids: &HashSet<Uuid>,
|
||||
path: impl AsRef<Path>,
|
||||
) -> Result<()> {
|
||||
let mut dump_data_file = NamedTempFile::new()?;
|
||||
let mut dump_data_file = NamedTempFile::new_in(&path)?;
|
||||
|
||||
self.dump_pending(txn, uuids, &mut dump_data_file, &path)?;
|
||||
self.dump_completed(txn, uuids, &mut dump_data_file)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue