libuptest 0.1.4

Core Substrate runtime upgrade Library for UpTest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use flate2::read::GzDecoder;
use std::fs::File; // todo change to tokio fs
use tar::Archive;

/// unzip a gzip file, like tar -xvf does on posix based systems
pub fn tar_xvf(filename: String) -> Result<(), Box<dyn std::error::Error>> {
    // Open the gzip file
    let file = File::open(filename)?;
    let decoder = GzDecoder::new(file);

    // Create a tar archive from the gzip file decoder
    let mut archive = Archive::new(decoder);

    // Extract the contents of the archive
    archive.unpack(".")?;
    Ok(())
}