From 844f0774018028b8e65e28445af4ac3dcd19d618 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 16 Mar 2024 10:56:15 +0100 Subject: [PATCH] shred: as we already got the metadata info, use it directly --- src/uu/shred/src/shred.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 8a73eb1f1..12cd67acd 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -474,7 +474,7 @@ fn wipe_file( let size = match size { Some(size) => size, - None => get_file_size(path)?, + None => metadata.len(), }; for (i, pass_type) in pass_sequence.into_iter().enumerate() { @@ -532,10 +532,6 @@ fn do_pass( Ok(()) } -fn get_file_size(path: &Path) -> Result { - Ok(fs::metadata(path)?.len()) -} - // Repeatedly renames the file with strings of decreasing length (most likely all 0s) // Return the path of the file after its last renaming or None if error fn wipe_name(orig_path: &Path, verbose: bool, remove_method: RemoveMethod) -> Option {