Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Vale LeBrock committed Jan 16, 2025
1 parent 1793079 commit 37dab03
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/unzip_temp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ use std::{
};
use tar::Archive;

// TODO: decompress the files on demand, and don't take up the disk space

// take a single archive file, and get the temp location of the unzipped file
// NOTE: you must return the TempPath to the caller so otherwise when it
// drops out of scope the files will be deleted, this is intentional.
pub fn test_helper_temp_unzipped(
archive_file: &Path,
tar_opt: bool,
) -> Result<(PathBuf, TempPath)> {
let temp_dir = TempPath::new();
temp_dir.create_as_dir()?;

let path = decompress_file(archive_file, temp_dir.path(), tar_opt)?;

Ok((path, temp_dir))
}

/// Decompresses a gzip-compressed file at `src_path` and saves the decompressed contents
/// to `dst_dir` with the same file name, but without the `.gz` extension.
fn decompress_file(src_path: &Path, dst_dir: &Path, tar_opt: bool) -> Result<PathBuf> {
Expand Down Expand Up @@ -152,3 +135,18 @@ pub fn maybe_handle_gz(archive_path: &Path) -> Result<(PathBuf, Option<TempPath>

Ok((archive_path.to_path_buf(), None))
}

// take a single archive file, and get the temp location of the unzipped file
// NOTE: you must return the TempPath to the caller so otherwise when it
// drops out of scope the files will be deleted, this is intentional.
pub fn test_helper_temp_unzipped(
archive_file: &Path,
tar_opt: bool,
) -> Result<(PathBuf, TempPath)> {
let temp_dir = TempPath::new();
temp_dir.create_as_dir()?;

let path = decompress_file(archive_file, temp_dir.path(), tar_opt)?;

Ok((path, temp_dir))
}

0 comments on commit 37dab03

Please sign in to comment.