Skip to content

Commit 3d78cb1

Browse files
authored
[Mellanox] Update the save_file command in generate_dump to handle folders (sonic-net#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.
1 parent 5086a43 commit 3d78cb1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

scripts/generate_dump

+15-9
Original file line numberDiff line numberDiff line change
@@ -1082,18 +1082,24 @@ save_file() {
10821082
fi
10831083

10841084
if $do_gzip; then
1085-
gz_path="${gz_path}.gz"
1086-
tar_path="${tar_path}.gz"
1087-
if $NOOP; then
1085+
if [ ! -d "$path" ]; then
1086+
gz_path="${gz_path}.gz"
1087+
tar_path="${tar_path}.gz"
1088+
1089+
if $NOOP; then
10881090
echo "gzip -c $orig_path > $gz_path"
1089-
else
1091+
else
10901092
gzip -c $orig_path > $gz_path
1091-
fi
1092-
else
1093-
if $NOOP; then
1094-
echo "cp $orig_path $gz_path"
1093+
fi
10951094
else
1096-
cp $orig_path $gz_path
1095+
gz_path="${gz_path}.tar.gz"
1096+
tar_path="${tar_path}.tar.gz"
1097+
1098+
if $NOOP; then
1099+
echo "tar -czvf $gz_path -C $(dirname $orig_path) $(basename $orig_path)"
1100+
else
1101+
tar -czvf "$gz_path" -C "$(dirname "$orig_path")" "$(basename "$orig_path")"
1102+
fi
10971103
fi
10981104
fi
10991105

0 commit comments

Comments
 (0)