[Dovecot] (Single instance) attachment storage with single-dbox
Timo Sirainen
tss at iki.fi
Tue Oct 19 19:28:54 EEST 2010
On Sat, 2010-09-25 at 13:34 +0100, Timo Sirainen wrote:
> But .. I suppose it could be possible to use a combination of attachment-id + mailbox GUID + message UID number. I'll have to think about it..
Implemented. Although saving messages now requires an extra rename(). It
should be possible to get rid of this at some point, but for now it
works like:
1. Attachment saving is first started to a temp file.
2. Attachment is written to temp file.
3. Attachment writing is finished and file is renamed to <hash>-<guid>
4. <possibly more attachments and messages are saved>
5. Index is locked, so new messages can be assigned IMAP UIDs
6. Attachments are renamed from <hash>-<guid> to
<hash>-<guid>-<mailbox_guid>-<imap_uid>
7. Index is unlocked
(Getting rid of step 3 would require some FS API changes.)
Copying works basically the same:
1. Source file's attachments are linked to a temp file in destination.
2. <possibly more attachments and messages are copied>
3. Index is locked, so new messages can be assigned IMAP UIDs
4. Attachments are renamed from temp files to
<hash>-<guid>-<mailbox_guid>-<imap_uid>
5. Index is unlocked
The attachment paths in dbox metadata contain only the <hash>-<guid>
part, so when accessing any attachments the <mailbox_guid>-<imap_uid>
must be manually appended to the path.
More information about the dovecot
mailing list