mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	fix dumpv1
This commit is contained in:
		| @@ -1,8 +1,9 @@ | ||||
| use std::fs::{create_dir_all, File}; | ||||
| use std::fs::{File, create_dir_all}; | ||||
| use std::io::Write; | ||||
| use std::path::Path; | ||||
|  | ||||
| use flate2::{read::GzDecoder, write::GzEncoder, Compression}; | ||||
| use flate2::read::GzDecoder; | ||||
| use flate2::{Compression, write::GzEncoder}; | ||||
| use tar::{Archive, Builder}; | ||||
|  | ||||
| pub fn to_tar_gz(src: impl AsRef<Path>, dest: impl AsRef<Path>) -> anyhow::Result<()> { | ||||
|   | ||||
| @@ -39,9 +39,9 @@ impl MetadataV1 { | ||||
|         ); | ||||
|  | ||||
|         let uuid_store = HeedUuidStore::new(&dst)?; | ||||
|         for index in self.indexes { | ||||
|         for index in dbg!(self.indexes) { | ||||
|             let uuid = Uuid::new_v4(); | ||||
|             uuid_store.insert(index.uid.clone(), uuid)?; | ||||
|             uuid_store.insert(dbg!(index.uid.clone()), dbg!(uuid))?; | ||||
|             let src = src.as_ref().join(index.uid); | ||||
|             load_index( | ||||
|                 &src, | ||||
| @@ -93,7 +93,7 @@ fn load_index( | ||||
|     size: usize, | ||||
|     indexer_options: &IndexerOpts, | ||||
| ) -> anyhow::Result<()> { | ||||
|     let index_path = dst.as_ref().join(&format!("indexes/index-{}", uuid)); | ||||
|     let index_path = dst.as_ref().join(&format!("indexes/{}", uuid)); | ||||
|  | ||||
|     create_dir_all(&index_path)?; | ||||
|     let mut options = EnvOpenOptions::new(); | ||||
|   | ||||
| @@ -109,6 +109,15 @@ pub fn load_dump( | ||||
|     update_db_size: usize, | ||||
|     indexer_opts: &IndexerOpts, | ||||
| ) -> anyhow::Result<()> { | ||||
|     // Setup a temp directory path in the same path as the database, to prevent cross devices | ||||
|     // references. | ||||
|     let temp_path = dst_path.as_ref().parent().map(ToOwned::to_owned).unwrap_or_else(|| ".".into()); | ||||
|     if cfg!(windows) { | ||||
|         std::env::set_var("TMP", temp_path); | ||||
|     } else { | ||||
|         std::env::set_var("TMPDIR", temp_path); | ||||
|     } | ||||
|  | ||||
|     let tmp_src = tempfile::tempdir()?; | ||||
|     let tmp_src_path = tmp_src.path(); | ||||
|  | ||||
| @@ -120,6 +129,8 @@ pub fn load_dump( | ||||
|  | ||||
|     let tmp_dst = tempfile::tempdir()?; | ||||
|  | ||||
|     println!("temp path: {}", tmp_dst.path().display()); | ||||
|  | ||||
|     match meta { | ||||
|         Metadata::V1(meta) => { | ||||
|             meta.load_dump(&tmp_src_path, tmp_dst.path(), index_db_size, indexer_opts)? | ||||
|   | ||||
| @@ -75,6 +75,7 @@ impl UpdateFileStore { | ||||
|  | ||||
|         create_dir_all(&dst_update_files_path)?; | ||||
|  | ||||
|         println!("src_update file: {}", src_update_files_path.display()); | ||||
|         let entries = std::fs::read_dir(src_update_files_path)?; | ||||
|  | ||||
|         for entry in entries { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user