Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'production')
-rwxr-xr-xproduction/sdk/cleaners/dailyCleanDownloads.sh18
1 files changed, 8 insertions, 10 deletions
diff --git a/production/sdk/cleaners/dailyCleanDownloads.sh b/production/sdk/cleaners/dailyCleanDownloads.sh
index c3868ba2a..1a31e6ea8 100755
--- a/production/sdk/cleaners/dailyCleanDownloads.sh
+++ b/production/sdk/cleaners/dailyCleanDownloads.sh
@@ -22,7 +22,7 @@ fi
echo -e "\n\tDaily clean of ${HOSTNAME} download server on $(date )\n"
#
-# Checks whether a build can be retained or not.
+# Checks whether a build can be retained or not.
# returns 0 if the build can be retained
#
function canBeRetained ()
@@ -46,7 +46,7 @@ function canBeRetained ()
function removeBuild ()
{
- buildName=$1
+ buildname=$1
rm -fr $buildname
RC=$?
if [[ $RC = 0 ]];then
@@ -90,7 +90,7 @@ areNotToDelete=$(printf '%s\n' "${newest[@]}" | paste -sd '|')
currentWeekNum=0 #week number from start of the year user to identify the week in which the build is created
found=0 #it will be 1 when we found a build that can be retained in that week
-
+
for buildname in ${allOldBuilds}; do
if [[ $buildname =~ $areNotToDelete ]]
then
@@ -98,7 +98,7 @@ for buildname in ${allOldBuilds}; do
else
buildId=$(basename $buildname) #extract buildId
yy=$(echo $buildId|cut -b2-5) #extract year from buildId
- mm=$(echo $buildId|cut -b6-7) #extract month
+ mm=$(echo $buildId|cut -b6-7) #extract month
dd=$(echo $buildId|cut -b8-9) #extract day
day=${mm}/${dd}/${yy} #construct build date
dayOfWeek=$(date -d $day +%u) #get the day of the week like monday, tue, etc
@@ -106,31 +106,29 @@ for buildname in ${allOldBuilds}; do
#special case for Sunday. unix considers sunday as the start of the week. but for us we need to consider
#monday as start of the week. For this purpose we subtract 1 to place the build in previous week
- if [ $dayOfWeek -eq 7 ]; then
+ if [ $dayOfWeek -eq 7 ]; then
weekNum=$(expr $weekNum - 1)
if [ $weekNum -le 0 ]; then #check for the yearend
weekNum=53
fi
fi
-
+
canBeRetained ${buildname}
retain=$?
if [ $weekNum -eq $currentWeekNum ]; then
if [ $retain -eq 0 -a $found -ne 1 ]; then # we didn't found a build that can be retained in the current week
found=1
- echo retaining $buildId
else
- echo removing $buildId
+ removeBuild $buildname
fi
else #week changed
currentWeekNum=$weekNum
found=0
if [ $retain -eq 0 -a $dayOfWeek -eq 1 ]; then
found=1
- echo retaining $buildId
else
- echo removing $buildId
+ removeBuild $buildname
fi
fi
fi

Back to the top