Skip to content

fix: use elif in progress.sh to prevent printing both hours and days estimates#81

Open
amathxbt wants to merge 1 commit intoinkonchain:mainfrom
amathxbt:fix/progress-sh-elif-display-logic
Open

fix: use elif in progress.sh to prevent printing both hours and days estimates#81
amathxbt wants to merge 1 commit intoinkonchain:mainfrom
amathxbt:fix/progress-sh-elif-display-logic

Conversation

@amathxbt
Copy link
Copy Markdown

Bug

progress.sh uses three independent if blocks for the sync time estimate display:

if [ $MINUTES -le 60 ] ; then
   echo "Sync will complete in minutes"
   echo "Minutes until sync completed: $MINUTES"
fi

if [ $MINUTES -gt 60 ] ; then
   echo "Sync will take hours"
   echo "Hours until sync completed: $HOURS"
fi

if [ $HOURS -gt 24 ] ; then
   echo "Sync will take days"
   DAYS=$((HOURS / 24))
   echo "Days until sync complete: $DAYS"
fi

When $HOURS > 24, both the second and third blocks execute, printing:

Sync will take hours
Hours until sync completed: 30
Sync will take days
Days until sync complete: 1

This is contradictory output — users see both "hours" and "days" simultaneously, making the information confusing and untrustworthy.

Fix

Replace with elif / else so only the most appropriate time unit is shown:

if [ $MINUTES -le 60 ]; then
   echo "Sync will complete in minutes"
   echo "Minutes until sync completed: $MINUTES"
elif [ $HOURS -le 24 ]; then
   echo "Sync will take hours"
   echo "Hours until sync completed: $HOURS"
else
   echo "Sync will take days"
   DAYS=$((HOURS / 24))
   echo "Days until sync complete: $DAYS"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant