From fe5e1ce7c2439f685556d4ba8e57535e5f4761db Mon Sep 17 00:00:00 2001 From: Mitch Zhu Date: Tue, 7 Jan 2025 02:10:22 +0000 Subject: [PATCH] Address comment --- src/tardev-snapshotter/src/snapshotter.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/tardev-snapshotter/src/snapshotter.rs b/src/tardev-snapshotter/src/snapshotter.rs index d81cf140d24f..34919c7220c5 100644 --- a/src/tardev-snapshotter/src/snapshotter.rs +++ b/src/tardev-snapshotter/src/snapshotter.rs @@ -884,16 +884,8 @@ impl TarDevSnapshotter { let name = dir.path().join(name_to_hash(&key)); trace!("Fetching {} layer image to {:?}", layer_type, name); self.get_layer_image(&name, digest_str).await?; - - // Rename the file with the correct extension - let target_name = { - let mut renamed = name.clone(); - renamed.set_extension(layer_type); - trace!("Renaming {:?} to {:?}", &name, &renamed); - std::fs::rename(&name, &renamed) - .map_err(|e| Status::internal(format!("Failed to rename file: {e}")))?; - renamed - }; + let mut target_name = name.clone(); + target_name.set_extension(layer_type); // Decompress and process the layer trace!("Decompressing {:?} to {:?}", &target_name, &name); @@ -909,9 +901,6 @@ impl TarDevSnapshotter { let mut gz_decoder = flate2::read::GzDecoder::new(compressed); std::io::copy(&mut gz_decoder, &mut file) .context("failed to copy payload from gz decoder")?; - } else { - let mut tar_file = fs::File::open(&target_name)?; - std::io::copy(&mut tar_file, &mut file).context("failed to copy payload from gz decoder")?; } trace!("Appending index to {:?}", &name);