Skip to content

Commit df2a1c7

Browse files
enhanced eta display
1 parent 88cc626 commit df2a1c7

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/fix.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ main(){
5050
cleanup(){
5151
rm_file "$LOCK_FILE"
5252
}
53-
53+
update_eta(){
54+
local expected_start=$(cat "$NEXT_TIME" 2>/dev/null || echo $start_time)
55+
local drift=$(( $start_time - $expected_start ))
56+
[ $drift -lt 0 ] && drift=0
57+
local execution_time=$(( $end_time - $start_time ))
58+
echo $(( $(date +%s) + 1800 + $drift + $execution_time )) > "$NEXT_TIME" # update next time
59+
}
5460
start_time=$(date +%s)
5561
if [ -e "$LOCK_FILE" ]; then
5662
export LOCKED=1
@@ -73,7 +79,7 @@ if [ $LOCKED -eq 1 ]; then
7379
echo -e "Another instance is running, exiting..."
7480
else
7581
if [ $CALL_FROM_DAEMON -eq 1 ]; then
76-
echo $(($(date +%s) + 1800 + $(($end_time - $start_time)))) > "$NEXT_TIME" # update next time
82+
update_eta
7783
else
7884
echo -e "\r[DONE] Fixed $COUNT apps in $(($end_time - $start_time))s. "
7985
fi

0 commit comments

Comments
 (0)