From f0cb22206c0f8c3fc979c83086ac55676687a7cf Mon Sep 17 00:00:00 2001 From: meek2100 <34908880+meek2100@users.noreply.github.com> Date: Fri, 23 May 2025 11:56:08 -0700 Subject: [PATCH] Improve logic around caching IPK so don't run opkg update multiple times. --- opkgscript.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/opkgscript.sh b/opkgscript.sh index aa9eaf3..44056d8 100755 --- a/opkgscript.sh +++ b/opkgscript.sh @@ -173,7 +173,21 @@ if [ $COMMAND = "cache-ipks" ] ; then echo "Running opkg update..." fi - opkg update + # Only update if lists are older than 5 minutes + CACHE_AGE_LIMIT=300 # seconds + needs_update=false + for list in /var/opkg-lists/*; do + if [ ! -f "$list" ] || [ "$(($(date +%s) - $(stat -c %Y "$list")))" -gt "$CACHE_AGE_LIMIT" ]; then + needs_update=true + break + fi + done + + if $needs_update; then + opkg update + else + echo "Skipping opkg update: cache is fresh" + fi if $VERBOSE; then echo "Finished opkg update"