X-Git-Url: https://plomlompom.com/repos/test.html?a=blobdiff_plain;f=buster%2Fhome_files%2Fuser%2Fmail_sync.sh;h=6962800090262de68539f10101f4fc36f6d62298;hb=2c4f190d4235f62b23fe31dc02ea9c09deed3177;hp=0837390302a4b9d05e55f5bfae163b74969a56be;hpb=72d0c7ff45225d7e122f752a95b24a126d5545ff;p=config
diff --git a/buster/home_files/user/mail_sync.sh b/buster/home_files/user/mail_sync.sh
index 0837390..6962800 100755
--- a/buster/home_files/user/mail_sync.sh
+++ b/buster/home_files/user/mail_sync.sh
@@ -1,9 +1,21 @@
#!/bin/sh
set -e
+basedir="/home/plom/mail/maildir/"
+# Ensure directories exist for all "dir:*" tags.
+for tag in $(notmuch search --output=tags '*'); do
+ if [ ! $(echo "${tag}" | cut -c-4) = "dir:" ]; then
+ continue
+ fi
+ target_dir="${basedir}"$(echo "${tag}" | cut -c5-)"/cur/"
+ if [ ! -d "${target_dir}" ]; then
+ echo "Directory ${target_dir} does not exist."
+ exit 1
+ fi
+done
+
# Ensure all "dir:*"-tagged mails are in proper directories,
# remove all "dir:*" tags.
-basedir="/home/plom/mail/maildir/"
for tag in $(notmuch search --output=tags '*'); do
if [ ! $(echo "${tag}" | cut -c-4) = "dir:" ]; then
continue