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 into
inkonchain: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 into
inkonchain: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

@kutluhaneth46 kutluhaneth46 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

The old progress.sh used three independent ifs, so a sync that is e.g. 30 hours away printed both the “hours” and “days” branches. Collapsing to if / elif / else makes the buckets mutually exclusive, which matches the intended UX.

LGTM — small, correct control-flow fix.

@kutluhaneth46 kutluhaneth46 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

The old progress.sh used three independent ifs, so a sync that is e.g. 30 hours away printed both the “hours” and “days” branches. Collapsing to if / elif / else makes the buckets mutually exclusive, which matches the intended UX.

Small, correct control-flow fix.

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.

2 participants