diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-03-22 14:28:45 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-03-22 14:31:15 -0700 |
commit | 8fcf5f6d2741e8bbe8b1d63d0a996503e25daabc (patch) | |
tree | 4227d134f0ead1aa68d0ea031a9cd66b6e6dc533 /bin/movemymail | |
parent | 35a8e2a4cc8d434d56a25ba52c4616f1b5d1c1b7 (diff) | |
download | dotfiles-8fcf5f6d2741e8bbe8b1d63d0a996503e25daabc.tar.gz |
move all mail new/ -> cur/ before notmuch sees it
Experimentally drop an older workaround.
See id:878rt122nj.fsf@melete.silentflame.com too.
Diffstat (limited to 'bin/movemymail')
-rwxr-xr-x | bin/movemymail | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/bin/movemymail b/bin/movemymail index bb99686b..60919320 100755 --- a/bin/movemymail +++ b/bin/movemymail @@ -13,15 +13,16 @@ use Net::Domain "hostfqdn"; open our $us, "<", $0 or die $!; exit 0 unless flock $us, LOCK_EX|LOCK_NB; +our $root = "$ENV{HOME}/.fmail"; +our $on_athena = hostfqdn eq "athena.silentflame.com"; + die "no movemymail\n" if -e "$ENV{HOME}/.nomovemymail"; -open my $df, "-|", "df", "-kP", "$ENV{HOME}/.fmail"; +open my $df, "-|", "df", "-kP", $root; <$df>, my @df_fields = split " ", <$df>; $df_fields[3] > 1048576 or die "free space low; no movemymail\n"; -our $on_athena = hostfqdn eq "athena.silentflame.com"; - # Sync notmuch's database to maildir and to git. -if (-d "$ENV{HOME}/.fmail/.notmuch/xapian") { +if (-d "$root/.notmuch/xapian") { # Skip on athena because it's v. slow atm. system "mr", "-d", "$ENV{HOME}/lib/nmbug-spw", "autoci" unless $on_athena; @@ -46,6 +47,15 @@ if ($on_athena) { system "imap-dl", "$ENV{HOME}/.config/mailscripts/imap-dl.catmail"; } +# Move all mail new/ -> cur/ such that notmuch never sees anything in new/. +# The reason for this is that notmuch tries to avoid moving files new/ -> cur/ +# to avoid confusing Mutt, but messages in new/ aren't meant to have flags, so +# they can't be marked seen. See id:87r1ypsb1p.fsf@tethera.net and maildir(5). +for (<$root/*/new/*>) { + m#^\Q$root\E/([^/]+)/new/([^/]+?)(:2,[^/]*)?$# or die "inadequate glob!"; + rename $_, "$root/$1/cur/$2" . ($3 || ":2,"); +} + # Useful to see if any mail has got stuck before closing laptop lid. `mailq` =~ "Mail queue is empty" or warn "WARNING: Outbox not empty.\n"; @@ -55,11 +65,11 @@ sub search2folder { "(", @terms, ")", "and", "not", "folder:$folder"; my @matches; for (<$search>) { - next if m{^$ENV{HOME}/.fmail/annex/}; + next if m{^\Q$root\E/annex/}; chomp; # If notmuch's database is out-of-date the file may no longer exist # because it's already been moved by a previous run of this script. -f and push @matches, $_ } - @matches and system "mdmv", @matches, "$ENV{HOME}/.fmail/$folder"; + @matches and system "mdmv", @matches, "$root/$folder"; } |