Skip to content

Commit 722d35f

Browse files
ggiguashagullon
andcommitted
Add extra check to not delete cache if only 1 exists
Co-authored-by: Alejandro Gullon <[email protected]>
1 parent fc61854 commit 722d35f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/bin/manage_build_cache.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,15 @@ action_keep() {
229229
# Get the last contents with the ${TAG_SUBDIR} default
230230
local -r last_dir="$(action_getlast | awk '/LAST:/ {print $NF}')"
231231

232-
for sub_dir in $(run_aws_cli s3 ls "${top_dir}/" | awk '{print $NF}'); do
232+
# Get all sub-directories in the top directory
233+
local -r sub_dirs=$(run_aws_cli s3 ls "${top_dir}/" | grep '/$' | awk '{print $NF}')
234+
# Skip if only one sub-directory exists
235+
if [ "$(echo "${sub_dirs}" | wc -w)" -eq 1 ] ; then
236+
echo "Only one sub-directory found in '${top_dir}', keeping it"
237+
return 0
238+
fi
239+
240+
for sub_dir in ${sub_dirs}; do
233241
if [ "${sub_dir}" = "last" ] ; then
234242
continue
235243
fi

0 commit comments

Comments
 (0)