From a552ddd1bd9b0f9867be206733627a9e9432a201 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Wed, 16 Sep 2009 23:28:31 -0500 Subject: [PATCH] updating the cache, handle it more efficiently --- bin/updates_available | 14 ++++---------- debian/changelog | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/bin/updates_available b/bin/updates_available index 51c4744d..4397c6a0 100755 --- a/bin/updates_available +++ b/bin/updates_available @@ -48,9 +48,6 @@ print_updates() { update_cache() { mycache=$1 - # Clear the cache, and background an immediate update. - rm -f $mycache - touch -t 197001010000 $mycache # Now we actually have to do hard computational work to calculate updates. # Let's try to be "nice" about it: renice 10 $$ >/dev/null 2>&1 || true @@ -83,14 +80,11 @@ PKG="byobu" [ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$HOME/.byobu" mycache="$DIR/$PKG.updates-available" +# If mycache is present, use it +[ -r $mycache ] && print_updates `grep "^[0-9]" $mycache | sed "s/ .*$//"` + +# Update the cache if necessary if [ "/var/lib/apt" -nt "$mycache" ] || [ "/var/lib/apt/lists" -nt "$mycache" ]; then # If apt is newer than mycache, background an update now update_cache "$mycache" fi -if [ -r $mycache ]; then - # If mycache is present, use it - print_updates `grep "^[0-9]" $mycache | sed "s/ .*$//"` -else - # Otherwise, background an update now - update_cache "$mycache" -fi diff --git a/debian/changelog b/debian/changelog index d422c3e7..a5ccf8c1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,12 +4,12 @@ byobu (2.33) unreleased; urgency=low temp_f, updates_available, wifi: make byobu status scripts friendlier for busybox environments (tested on the Palm Pre), LP: #430096 * bin/updates_available: print the current cache even if we're - updating the cache + updating the cache, handle it more efficiently * po/byoub-*.po: rename to just *.po, fix translations location, LP: #430095 * debian/control: drop update-notifier-common and lsb-release to suggests, as we can live without these now - -- Dustin Kirkland Wed, 16 Sep 2009 16:46:57 -0500 + -- Dustin Kirkland Wed, 16 Sep 2009 23:28:02 -0500 byobu (2.32-0ubuntu1) karmic; urgency=low