https://gitlab.synchro.net/main/sbbs/-/commit/01d02e610d1759274b147ccf
Added Files:
exec/tests/mailbox/store_quota.js exec/tests/user/mailbox_full/quota_library.js
Modified Files:
exec/load/mailbox.js mailbox_files.js mailbox_summary.js exec/tests/mailbox/store_limits.js store_rows.js store_star.js store_write.js exec/tests/user/mailbox_full/quota_child.inc exec/tests/webmail/api.js webmail/lib/api.js webmail/lib/locale/en_us.ini webmail/root/css/style.css webmail/root/js/folders.js mail.js settings.js
Log Message:
WebMail: the mailbox quota covers the Inbox
The mailbox library (exec/load/mailbox.js) counted only the private base against the mailbox quota, so WebMail's meter left out the Inbox, and the
quota was applied where it no longer makes sense: a move from the Inbox
into a folder was refused, or removed the oldest Trash, although the
message takes the same space in either place.
The library:
- usage() returns { bytes, quota, full }: bytes is the private base plus
the user's mail in the shared base (Inbox and Spam), full is true once
bytes reaches the quota. overview() returns folders() and usage() from
one pass over the mail index, for folder.list.
- No move is refused for the quota and none removes Trash: Inbox to a
folder or Archive, to Trash, back to the Inbox. The "quota" error no
longer comes from a move.
- A Sent copy is the one thing the library still checks, now against all
of the user's mail: the oldest Trash is removed to make room, and when
that would not be enough the copy is not kept and nothing is removed
(WebMail sends anyway and says no copy was kept, as before).
- An Inbox message's size counts its attached files, as a filed message's
does, so filing does not move the meter (the facts cache version is
raised: each user's cache is rebuilt once).
- The private base's total is written to
data/user/NNNN/mailbox.usage.ini ("bytes=<n>") for the servers, which
apply the quota to new mail (user_mailbox_full()). Written under the
state lock by the same replace-by-rename as the JSON side files, when
the total changes and when the file is missing; a failed write is
logged and the servers then count the base's file sizes.
WebMail:
- folder.list's usage is that figure, and the meter and the settings page
show it. At the quota a line under the meter says that new mail is
being refused and to delete messages and empty Trash. Old Trash is not
removed automatically for it.
- A user with the W exemption gets a store without a quota: nothing is
refused, no Trash is removed for room, and the meter shows the usage
with no limit and no bar.
For users: the meter now shows all of their mail, so it jumps for anyone
with a large Inbox. Deleting moves mail to Trash, which still counts:
room comes from emptying Trash.
Measured on a copy of a mail base's index and headers (9,262 records),
local disk, warm caches, one store per call as the API makes: folders()
plus usage() before against overview() after took 100 to 102 ms and 102
to 103 ms for an Inbox of 5,486 messages, 37 to 38 and 38 to 39 ms for
919, 27 to 28 ms both for 24. A send adds one index pass for the Sent
copy's check: 26 to 85 ms on the same copy.
Tested by script: exec/tests/mailbox/store_quota.js (usage with Inbox,
Spam, another user's mail and an attached file; mailbox.usage.ini after
a move, a delete, a flag change, a Sent copy, a Trash purge by age and
emptying Trash, rewritten when missing and left alone for an unchanged
total; deleting and filing over the quota; a Sent copy refused, kept, and
kept by removing Trash, against Inbox mail; no quota), the changed quota sections of store_write.js and store_limits.js, exec/tests/webmail/api.js (usage and full through folder.list, the W exemption, one index pass)
and exec/tests/user/mailbox_full/quota_library.js (User.mailbox_full()
agrees with the library's total at the quota and one block under it,
from the file the library wrote). The meter and its warning were not
seen in a browser.
Co-Authored-By: Claude Fable 5.2 <
noreply@anthropic.com>