Improve logic around caching IPK so don't run opkg update multiple times.

This commit is contained in:
meek2100 2025-05-23 11:56:08 -07:00 committed by GitHub
parent 953c80e2cf
commit f0cb22206c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"