BBS:      TELESC.NET.BR
Assunto:  src/sbbs3/js_filebase.cpp
De:       Rob Swindell (on Windows 11)
Data:     Thu, 14 May 2026 02:49:16 -0700
-----------------------------------------------------------
https://gitlab.synchro.net/main/sbbs/-/commit/1767046fd69fbcda29d09372
Modified Files:
	src/sbbs3/js_filebase.cpp
Log Message:
js_filebase: initialize SMB_FILE_DIRECTORY for fresh ad-hoc (is_path) bases

For an is_path FileBase, js_open() called smb_open() directly instead
of smb_open_dir(). smb_open_dir() initializes a fresh file base by
setting status.attr = SMB_FILE_DIRECTORY (and any dir-specific limits)
then calling smb_create() to write the SMB header to disk. Plain
smb_open() does neither  it just opens the .shd file (creating an
empty one if absent) and reads existing status only if the file is
already big enough.

Without SMB_FILE_DIRECTORY in status.attr, smb_idxreclen() (smblib.c)
returns sizeof(idxrec_t) (smaller, msg-style) instead of
sizeof(fileidxrec_t). That meant smb_addfile() wrote a corrupted
.sid index  small msg records where the rest of FileBase expects
file records  and loadfilenames(), iterating the index using
sizeof(fileidxrec_t), saw garbage / zero records. Net effect: add()
returned true, but get(), get_list(), and get_names() never found the
added file.

Reproducer:
  var fb = new FileBase(system.temp_dir + "x", true);
  fb.open();
  fb.add({name: "f.dat", desc: "d", from: "u"});
  fb.get("f.dat");        // -> null
  fb.get_list().length;   // -> 0

Fix: when js_open()'s !dirnum_is_valid (is_path) branch is taken and
smb_open() succeeds against an empty .shd, set status.attr =
SMB_FILE_DIRECTORY and call smb_create()  mirroring smb_open_dir()'s
first-time-init for ad-hoc bases. Like the savemsg/votemsg fix in
e5ddda76d, this is a latent bug exposed when 93b4d946c added the
is_path constructor option.
n
---
  mSynchronetn  hgVertrauen n hHome of Synchronet n gh[vert/cvs/bbs].synchro.net

-----------------------------------------------------------
[Voltar]