From 3d78cb16607d3071b902ca582f4e1fb60c45c951 Mon Sep 17 00:00:00 2001 From: DavidZagury <32644413+DavidZagury@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:18:08 +0200 Subject: [PATCH] [Mellanox] Update the save_file command in generate_dump to handle folders (#3631) - What I did Support saving folders. - How I did it Add a check to the save_file command, if the path that was provided is to a folder, use an appropriate method. - How to verify it Previously when a folder was given to be saved using this function, an empty file with the folder name would be created. --- scripts/generate_dump | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index 098f75e9f9..6011344fe3 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -1082,18 +1082,24 @@ save_file() { fi if $do_gzip; then - gz_path="${gz_path}.gz" - tar_path="${tar_path}.gz" - if $NOOP; then + if [ ! -d "$path" ]; then + gz_path="${gz_path}.gz" + tar_path="${tar_path}.gz" + + if $NOOP; then echo "gzip -c $orig_path > $gz_path" - else + else gzip -c $orig_path > $gz_path - fi - else - if $NOOP; then - echo "cp $orig_path $gz_path" + fi else - cp $orig_path $gz_path + gz_path="${gz_path}.tar.gz" + tar_path="${tar_path}.tar.gz" + + if $NOOP; then + echo "tar -czvf $gz_path -C $(dirname $orig_path) $(basename $orig_path)" + else + tar -czvf "$gz_path" -C "$(dirname "$orig_path")" "$(basename "$orig_path")" + fi fi fi