mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
restore snapshots
This commit is contained in:
parent
b9d189bf12
commit
90018755c5
15 changed files with 397 additions and 317 deletions
26
meilisearch-lib/src/compression.rs
Normal file
26
meilisearch-lib/src/compression.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use std::fs::{create_dir_all, File};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
use flate2::{read::GzDecoder, write::GzEncoder, Compression};
|
||||
use tar::{Archive, Builder};
|
||||
|
||||
pub fn to_tar_gz(src: impl AsRef<Path>, dest: impl AsRef<Path>) -> anyhow::Result<()> {
|
||||
let mut f = File::create(dest)?;
|
||||
let gz_encoder = GzEncoder::new(&mut f, Compression::default());
|
||||
let mut tar_encoder = Builder::new(gz_encoder);
|
||||
tar_encoder.append_dir_all(".", src)?;
|
||||
let gz_encoder = tar_encoder.into_inner()?;
|
||||
gz_encoder.finish()?;
|
||||
f.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
//pub fn from_tar_gz(src: impl AsRef<Path>, dest: impl AsRef<Path>) -> anyhow::Result<()> {
|
||||
//let f = File::open(&src)?;
|
||||
//let gz = GzDecoder::new(f);
|
||||
//let mut ar = Archive::new(gz);
|
||||
//create_dir_all(&dest)?;
|
||||
//ar.unpack(&dest)?;
|
||||
//Ok(())
|
||||
//}
|
Loading…
Add table
Add a link
Reference in a new issue