I've updated the proxy plugin at http://dovecot.org/patches/1.0/quota.c. It doesn't exactly work, even against latest CVS Dovecot as it crashes in save/copy, but it shows how it's basically going to work. Pretty ugly to do objects with C, but works..
If you're interested about writing support for some specific quota backend (maildir++, sql, ..), now would be a good time to begin :)
Well, the reason it crashes is because it needs to find out the message's size, but Dovecot doesn't yet really like being asked about messages that haven't been committed to index. I guess that needs to change, hopefully won't require too large changes. I think I'm going to merge mail-index-view and mail-index-transaction into same thing..
On Mon, 2004-06-21 at 21:00, Timo Sirainen wrote:
I've updated the proxy plugin at http://dovecot.org/patches/1.0/quota.c.
Eeh.. Quota plugin, of course. I mixed up quota and proxy words way too much yesterday when I had to modify both the class proxying code which enables writing plugins more easily as well as the quota plugin.
Today with latest CVS code the latest quota plugin fully works with mbox.
Except.. I think the logic needs some more thinking. When exactly is the quota updated? Is it our responsibility to update quota for changes made by others then Dovecot? Currently it updates only it's own changes.
Maybe it would be better to implement like:
- Hook into save/copy commands
Decrease quota_left internally for each mail, if it ever would become negative, fail the save/copy command. when the whole transaction is complete, update the quota backend.
- Hook into syncing
For each external newly appeared mail, increase the quota (our save/copy hook already updated it for internally created mails).
For each internal or external expunge, decrease the quota.
If we don't know expunged mail's size anymore (external expunge and we hadn't cached it's size), we need to recalculate quota. Stop calculating quota for the rest of the syncing session, and at the end do the recalculating by summing size of all existing messages.
Currently it's not possible to hook into syncing, I have to think how that'd work.. It would probably need to hook between index <-> storage syncing, not between client <-> storage. Although the latter would work, the actual message has always been deleted at that point and there's less chance of getting it's size.
participants (1)
-
Timo Sirainen