• src/sbbs3/upgrade_to_v319.c

    From Rob Swindell (on Debian Linux)@1:103/705 to Git commit to main/sbbs/master on Sunday, August 09, 2026 07:19:11
    https://gitlab.synchro.net/main/sbbs/-/commit/4cf8e2f01b9eb7f374393b9e
    Modified Files:
    src/sbbs3/upgrade_to_v319.c
    Log Message:
    upgrade_to_v319: read the legacy index before smb_create() destroys the base

    smb_create() truncates .shd to the base header, and .sdt and .sid to zero.
    It was called before the directory's legacy .ixb was opened, so a directory with no legacy data to convert had its file base emptied and was only then skipped -- the check that should have made it a no-op ran after the
    destruction it was meant to prevent.

    Under -f that turned "reset this base to its pre-3.19 contents" into "erase it", which also means removing the now-vestigial .ixb/.dat/.exb/.dab files
    made an accidental run strictly more destructive rather than safer.

    Read and validate the .ixb first and skip the directory before touching anything; only then open the extended-description file and create the base.
    The early-exit paths no longer need closeextdesc() because the file is not
    open yet, and the smb_create() failure path now releases the index buffer
    and the extended-description file, which it does have open by that point.

    A directory with no legacy data is now left untouched rather than
    initialized as an empty v3.19 base. That is harmless: smb_open_dir()
    already creates any file base whose .shd is empty, so such a directory is initialized on first use.

    Complements 46e06da739 (desk-5-these, 2026-05-27), which stopped a run
    without -f from clobbering an already-upgraded base.

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)