]> git.donarmstrong.com Git - bin.git/commitdiff
update_lists handles different mail directories
authorDon Armstrong <don@donarmstrong.com>
Sat, 13 Mar 2021 15:44:11 +0000 (07:44 -0800)
committerDon Armstrong <don@donarmstrong.com>
Sat, 13 Mar 2021 15:44:11 +0000 (07:44 -0800)
update_lists

index d398991011de6864759149ede8de7300ab1cc48c..6f7548f0b54750c272676b38bf2e33c539a581d4 100755 (executable)
@@ -1,17 +1,17 @@
 #!/bin/bash
 
-for listdir in lists bugs; do
-    ( cd ~/Maildir;
-       find $listdir -maxdepth 1 -mindepth 1 -type d | \
-           perl -ne 'chomp; $a = $_; $b = $a; $b =~ s/\./_/g; $b =~ s/\//./g; qx(ln -sf "$a" ".$b")';
-    );
-    ( cd ~/Maildir/$listdir; 
-       find . -maxdepth 1 -mindepth 1 -type d| \
-           xargs -n 1 -i bash -c 'A={}; (( $(find "$A" -type f -name "*" -not -name "dovecot*" -not -name ".imap*" -not -name ".customflags" | wc -l) == 0 )) && rm -rf "$A"';
-    );
-done;
+set -e
 
-# Remove broken symlinks
-(cd ~/Maildir;
-    find . -maxdepth 1 -mindepth 1 -type l -iname '.*' -not -xtype d -delete;
-);
+for maildir in Maildir Mail; do
+    if ! [ -e ~/$maildir ]; then
+        continue
+    fi;
+    ( cd ~/$maildir ;
+      for listtype in lists bugs; do
+          find . -maxdepth 1 -mindepth 1 -type d -iname "$listtype"'.*' -print0|
+              xargs -0 -i bash -c 'A={}; (( $(find "$A" -type f -name "*" -not -name "dovecot*" -not -name ".imap*" -not -name ".customflags" | wc -l) == 0 )) && rm -rf "$A"';
+      done;
+      find . -maxdepth 1 -mindepth 1 -type l -iname '.*' -not -xtype d -delete;
+    );
+    exit 0;
+fi;