More robust checking of age of apt cache

This commit is contained in:
John Hughes 2023-02-01 15:43:20 +01:00
parent 9b2b4f2004
commit 5953485018

View file

@ -45,12 +45,11 @@ log "done"
log_empty_line
log "Updating APT package list..."
last_update_delta_s=$(($(date +%s) - $(date +%s -r /var/cache/apt/pkgcache.bin)))
if test $last_update_delta_s -gt 300; then
if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5)" ]]; then
sudo apt-fast update > /dev/null
log "done"
else
log "skipped (fresh by ${last_update_delta_s} seconds)"
log "skipped (fresh within at least 5 minutes)"
fi
log_empty_line