nedmail:delete with another mbox bound over /mail/fs/mbox deletes from original /mail/fs/mbox

Thu, 5 Oct 2017 12:37:00 EDT
inkswinc@[REDACTED]

Hi,

upas/nedmail has some unexpected/weird behavior when using multiple/named mboxes with bind. If I:

; upas/fs -f /imaps/imap.gmail.
com/inkswinc@[REDACTED] ; echo open /imaps/imap.gmail.
com/inkswinc@[REDACTED] othermbox > /mail/fs/ctl ; bind /mail/fs/othermbox /mail/fs/mbox ; upas/nedmail : 1d : y

nedmail shows the mail from othermbox as expected, but attempts to delete message 1 from the original mbox. I’ve unintentionally deleted a handful of mail from the wrong mbox this way; it’s hazardous.

Less dangerous but still annoying: if there was no original mbox (you created one via `aux/stub -d' for the bind), no error is shown and the messages disappear from the nedmail window, but they’re back the next time you open it, because nedmail tried to delete them from an mbox that doesn’t exist.

Looking at /sys/src/cmd/upas/ned/nedmail.c flushdeleted(), it looks like it deletes mail via ‘delete $mbox $n’ messages to /mail/fs/ctl. This is flawed in that here $mbox means something different to the ctl file than it does in the namespace, so reads and writes end up using different sources.

I believe a valid approach would be to only use this when the -f or -s arguments are specified to nedmail, if at all. Otherwise just remove the /mail/fs/$mbox/$n directory, as this also serves the purpose of deleting the mail and respects any changes in the namespace.

If no one else gets around to implementing this I will probably try it myself at some point, but I can’t promise a timeline.