Skip to content

Commit 6ebeec3

Browse files
committed
AppRun: if update is due, touch first
If ULTRAGRID_AUTOUPDATE is set and the update is due, touch the AppImage first. This is convenient if user wants to skip the update eg. by pressing Ctrl-C, next run will not enforce the update becauuse the date of the file is reset. User can run then run the AppImage by issuing the command again without the update. + notice that updating because of ULTRAGRID_AUTOUPDATE is set + rename handle_updates to handle_autopudates (the normal update by -u is not handled by that function at all)
1 parent 2365a00 commit 6ebeec3

File tree

1 file changed

+9
-5
lines changed
  • data/scripts/Linux-AppImage

1 file changed

+9
-5
lines changed

data/scripts/Linux-AppImage/AppRun

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ usage_aux() {
7676
update_check_days=90
7777
## Trigger update if $ULTRAGRID_AUTOUPDATE days passed.
7878
## If $ULTRAGRID_AUTOUPDATE unset or empty, print update hint if UG binary is older than $update_check_days days.
79-
handle_updates() {(
79+
handle_autoupdates() {(
8080
if [ "${ULTRAGRID_AUTOUPDATE-0}" -eq -1 ]; then
8181
return
8282
fi
@@ -95,6 +95,11 @@ handle_updates() {(
9595
return
9696
fi
9797
if [ "${ULTRAGRID_AUTOUPDATE-}" ] && [ "$ULTRAGRID_AUTOUPDATE" -ge 0 ]; then
98+
echo "Running the UltraGrid update because the interval" \
99+
"specified by ULTRAGRID_AUTOUPDATE env variable has passed..."
100+
# update AppImage mtime otherwise if there are no updates
101+
# after elapsing the interval, the check would run always
102+
touch "$APPIMAGE"
98103
if "$DIR/appimageupdatetool" -j "$APPIMAGE"; then
99104
debug_msg "No UltraGrid AppImage update available"
100105
else
@@ -105,7 +110,6 @@ handle_updates() {(
105110
exec "$APPIMAGE" "$@" # launch updated version
106111
fi
107112
fi
108-
touch "$APPIMAGE" # update AppImage mtime otherwise if there are no updates after elapsing the interval, the check would run always
109113
return
110114
fi
111115
printf "UltraGrid binary older than %d days, consider checking updates:\n" "$update_check_days"
@@ -384,7 +388,7 @@ if [ "${APPIMAGE_DEBUG-undef}" = undef ] && [ "${ULTRAGRID_VERBOSE-}" ]; then
384388
fi
385389

386390
if [ $# -eq 0 ] || [ "${1-}" = "--gui" ]; then
387-
handle_updates "$@"
391+
handle_autoupdates "$@"
388392
if [ $# -eq 0 ]; then usage; else shift; fi
389393
if [ -x "$DIR/usr/bin/uv-qt" ]; then
390394
run uv-qt --with-uv "$DIR/usr/bin/uv" "$@"
@@ -393,7 +397,7 @@ if [ $# -eq 0 ] || [ "${1-}" = "--gui" ]; then
393397
exit 1
394398
fi
395399
elif [ "$1" = "-o" ] || [ "$1" = "--tool" ]; then
396-
handle_updates "$@"
400+
handle_autoupdates "$@"
397401
TOOL=$2
398402
shift 2
399403
if [ "$TOOL" = help ]; then
@@ -422,6 +426,6 @@ elif [ "$1" = "-u" ] || [ "$1" = "--update" ]; then
422426
touch "$APPIMAGE" # update AppImage mtime to avoid update notices if there are no updates avalable but were checked for
423427
"$DIR/appimageupdatetool" ${1+"$@" }"$APPIMAGE"
424428
else
425-
handle_updates "$@"
429+
handle_autoupdates "$@"
426430
run uv "$@"
427431
fi

0 commit comments

Comments
 (0)