[Dovecot] (Single instance) attachment storage with single-dbox
tss at iki.fi
Sat Sep 25 15:34:37 EEST 2010
On 25.9.2010, at 11.50, William Blunn wrote:
>> I can't think of any other reasonable way to handle this though, so unless someon has some great ideas, I think the solution is to simply
>> add enough warnings that message store shouldn't be accessed directly. Maybe add some import/export commands to doveadm which can be used to add a bunch of mails to storage without doing it directly on filesystem.
> Conceptually there is an attachment table with a primary key, and a message table which has foreign keys referring into the attachment table. In database theory, you could set up a foreign key constraint, and then it would not be possible to remove attachments which were still referenced by messages.
> I'm not saying all this data should be under *SQL; just thinking aloud.
> Can we do something /like/ that but only using a filesystem?
> Perhaps each message could have its own hard links to the attachment file? That way a message's attachments would be kept in existence by the filesystem itself.
That's basically how it works for most messages. The attachment ID is stored in the dbox metadata and for each message it's a unique ID which is a hard link to the original message. The problem is that when copying a message with hard linking you can't give a new attachment ID, because the message contents can't be updated.
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..
> When you store a message with attachments, you could store the message file:
> and have its attachments stored as hard links under names which appear adjacent to the message file's name when the directory listing is sorted.
> Because the attachment files are adjacently-named to the message file, people accessing the sdbox mailstore as a filesystem should realise that they must backup/restore the message file and its associated attachment files.
The attachments aren't stored in the same directory as the message files. That would make it work badly when multiple mount points exist.
More information about the dovecot