Skip to content

Commit

Permalink
feat: additional logging for uncompression.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Dec 14, 2024
1 parent 411f3e4 commit 28e461b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/subcommands/main_subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl CustomTransferAgent for MainSubcommand {
let mut target_file_path = file_station.download(source_file_path.as_str(), target_directory_path.as_path(), Some(progress_reporter)).await?;

if source_file_compressed {
target_file_path = self.uncompress_file(&target_file_path)?;
target_file_path = self.uncompress_file(&target_file_path).await?;
}

info!("Download finished");
Expand Down Expand Up @@ -309,9 +309,14 @@ impl MainSubcommand {
path == "/" || path.is_empty()
}

fn uncompress_file(&self, source_path: &PathBuf) -> Result<PathBuf> {
#[tracing::instrument]
async fn uncompress_file(&self, source_path: &PathBuf) -> Result<PathBuf> {
if let Some(extension) = source_path.extension() {
info!("Found extension: {}", extension.to_string_lossy());

if extension == ".zstd" {
info!("Found zstd compression, uncompressing.");

let source_path_string = source_path.to_string_lossy();
let split_pos = source_path_string.char_indices().nth_back(5).context("Should have more than 5 characters.")?.0;
let mut target_path = PathBuf::new();
Expand All @@ -322,6 +327,8 @@ impl MainSubcommand {

zstd::stream::copy_decode(source_file, target_file)?;

remove_file(source_path).await?;

return Ok(target_path);
}
}
Expand Down

0 comments on commit 28e461b

Please sign in to comment.