methodtMaildir.MailboxQuota
function MailboxQuota(const aMailbox: string; out aUsed, aLimit: Int64): Boolean;
THE QUOTA OF ONE MAILBOX. aMailbox is its directory name, as ResolveMailbox gives it, so an alias that resolves to a mailbox is counted against that mailbox. aUsed is the octets of its message files, INBOX and every folder; aLimit is Quota, or what OnMailboxQuota made of it; True when aLimit is a limit (not 0).
THE USAGE IS MAINTAINED, NOT WALKED PER QUESTION. The first question about a mailbox counts its files (new/ and cur/ of INBOX and of each folder); after that a delivery, APPEND and COPY add to the count and EXPUNGE and MOVE out of the account take from it, and DELETE of a folder makes the next question count again. The count is kept in memory only, per store root and process, so nothing written to disk can disagree with the files after a crash: a restart counts each mailbox again when it is first asked about. A file another program adds or removes is in the count when it is counted again, at most cMailQuotaRecountSeconds later, or at once after RecountUsage. A delivery or removal that happens while the mailbox is being counted can be counted twice or not at all until the next count.