This one is a bit of a doozy. A summary of the changes:
- Session has grown storage for attachments which have been uploaded but
not yet sent.
- The list of attachments on a message is refcounted so that we can
clean up the temporary files only after it's done with - i.e. after
copying to Sent and after all of the SMTP attempts are done.
- Abandoned attachments are cleared out on process shutdown.
Future work:
- Add a limit to the maximum number of pending attachments the user can
have in the session.
- Periodically clean out abandoned attachments?
The timer channel may already have been drained by `case <-timer.C`. In
this case, we need not to drain it again or we'll block forever.
To fix this, stop draining the timer channel. Since we're not going to
use the timer again anyway, it should be fine.
The session manager has been upgraded to deal with reconnections.
Each session has its own expiration timer. Each time a request is
received, the expiration timer is reset.
A session can be closed (this is used when the user wants to logout).
When the IMAP connection is closed by the server, it's set to nil in the
session. The next time an IMAP command needs to be issued, the
connection is re-established.
Closes: https://todo.sr.ht/~sircmpwn/koushin/30