archive-mail

Maintains maildir archives synced with current maildirs

git clone https://git.8pit.net/archive-mail.git

 1mmkdir() {
 2	for maildir in "$@"; do
 3		mkdir -p "${maildir}/new" "${maildir}/cur" "${maildir}/tmp"
 4	done
 5}
 6
 7add_mail() {
 8	mail="$(cat)" # absorb here document
 9	for path in "$@"; do
10		echo "${mail}" > "${path}"
11	done
12}
13
14check_maildir() {
15	diffout="$(diff -ur "${1}" "${2}")"
16	if [ $? -ne 0 ]; then
17		printf "FAIL: Directories differ.\n\n%s\n" "${diffout}"
18		exit 1
19	fi
20}
21
22run_test() {
23	cp -r current current.bkp
24	"${ARCHIVE_MAIL}" current→archive
25
26	check_maildir archive expected
27	if ! diff -r current.bkp current >/dev/null; then
28		printf "FAIL: current was modified\n"
29		exit 1
30	fi
31}