]> git.donarmstrong.com Git - bin.git/commitdiff
delete empty mailboxes on getmail
authorDon Armstrong <don@donarmstrong.com>
Sun, 19 Feb 2006 06:01:59 +0000 (06:01 +0000)
committerDon Armstrong <don@donarmstrong.com>
Sun, 19 Feb 2006 06:01:59 +0000 (06:01 +0000)
getmail

diff --git a/getmail b/getmail
index b824fab4e5b13b7643e12c3748c9ab3be4a9cd85..d13d872f48bb568068bb92ec587a3451dee7e853 100755 (executable)
--- a/getmail
+++ b/getmail
@@ -15,9 +15,16 @@ fi;
 # See if the server exists
 if [ -z "$CRON" ] || kill -0 `pgrep -U $(id -u) -x $MUA` 2>/dev/null; then
     if ping -q -c 3 $IMAPHOST >/dev/null 2>&1; then
-       nice -n 19 offlineimap -o -u Noninteractive.Basic 2>&1 |grep validity| \
+       if nice -n 19 offlineimap -o -u Noninteractive.Basic 2>&1 |grep validity| \
            perl -ne 'my ($account,$list) = /UID validity problem for folder ([\w-]+)\.([\w-]+)/;
                       next unless defined $account and length $account;
                       qx(/home/don/bin/deletemailbox -a $account $list > /dev/null);';
+           # Clean the lists up too
+           for account in bugs lists; do
+               find /home/don/Mail/$account -maxdepth 1 -mindepth 1 -type d \
+                   -exec sh -c 'test $(find {} -type f |wc -l) -eq 0' ';' \
+                   -printf '%f\000'|xargs -0 -n 1 ~/bin/deletemailbox -a $account >/dev/null
+           done;
+       fi;
     fi;
 fi;