https://gitlab.synchro.net/main/sbbs/-/commit/16ac50f67a1f5df0cbd4dfa8
Added Files:
exec/tests/msgbase/copy_msg.js email_path.js parts.js purge.js save_from_file.js
Modified Files:
src/sbbs3/js_msgbase.cpp load_cfg.c src/smblib/smbdefs.h smblib.h smbtxt.c
Log Message:
MsgBase: methods for a per-user e-mail base and large messages
New JavaScript MsgBase methods and options, groundwork for a per-user
mailbox (folders, Sent copies, Trash) kept outside the shared mail base:
- new MsgBase(path, true, true) creates a path-opened base as an e-mail
base: index records carry user numbers and duplicate messages are not
rejected. Creation and the type check run under the header lock, so
concurrent first opens of a new base cannot wipe each other's saves.
- copy_msg() and move_msg() copy a message to another open base through
native memory, rebuilding the index for the destination's type and
clearing the thread links. move_msg() flags the source deleted under
the header lock and undoes the copy if that fails, so a failed move
leaves the original and two concurrent moves leave one copy. File
attachments stay with the moved message.
- save_msg_from_file() saves a message whose body is read from a file,
and a rcpt_list entry may carry its own netattr.
- save_msg() now stores the header properties mime_version and
content_type (documented but previously ignored) as header lines,
unless the header already has them.
- get_msg_parts() lists a message's MIME parts and save_msg_part()
writes one decoded part, or the whole body, to a file. They use a new
bounded MIME walker and binary-safe decoders in smblib
(smb_getmimeparts, smb_decodemimepart, smb_freemimeparts).
- purge() frees the deleted messages of a path-opened base. It is
refused on the mail base, configured subs and file bases.
An e-mail-type base other than the system mail base always uses
self-packing storage, whatever the "MailBase Storage Method" setting:
nothing else packs such a base, so the space purge() frees must be
reused. With a throwaway configuration set to Fast Allocation, saving
three 20 KB messages, purging one and saving another grew the data file
from 60672 to 80896 bytes before this rule and left it at 60672 after.
copy_msg(), move_msg(), get_msg_parts() and save_msg_part() refuse a
message number that is not a number or is 0, which would otherwise
select the oldest message in the base.
Tests are in exec/tests/msgbase. The creation and double-move races
were verified with manual multi-process runs (500 rounds of 8 and of 2
jsexec processes) since no single-process test can reach them. The
MIME walker was run under valgrind. Built with GCC only; not yet built
with Clang or MSVC.
Co-Authored-By: Claude Fable 5.2 <
noreply@anthropic.com>
--- SBBSecho 3.38-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)