X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=buster%2Fhome_files%2Fuser%2Fmail_sync.sh;fp=buster%2Fhome_files%2Fuser%2Fmail_sync.sh;h=6962800090262de68539f10101f4fc36f6d62298;hb=8675c2980ee6fda4c582789465aa11b58243a7b8;hp=0837390302a4b9d05e55f5bfae163b74969a56be;hpb=f8d7547f67a6f96105c3d3d730eaca046ad264da;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