]> git.hungrycats.org Git - bees/commitdiff
hash: fix beesstats.txt write guard for inert home_fd
authorZygo Blaxell <bees@furryterror.org>
Mon, 27 Apr 2026 20:08:51 +0000 (16:08 -0400)
committerZygo Blaxell <bees@furryterror.org>
Tue, 6 Oct 2026 05:51:40 +0000 (01:51 -0400)
The hash-prefetch loop in BeesHashTable::prefetch_loop() guards the
on-disk stats-file write with `if (m_ctx->home_fd())`, intending to
skip the write when paths.home is unavailable (state.persistent=no
with the directory missing).  The guard never worked: crucible's Fd
exposes `operator int() const` (returns -1 when empty) and
`bool operator!() const` but no `operator bool()`, so `if (fd)` falls
through to the int conversion and `if (-1)` is unconditionally truthy.

Use `!!m_ctx->home_fd()` to force the operator! path, matching the
existing project idiom.

Assisted-by: Claude-Code:claude-opus-4-7
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-hash.cc

index e9da900629f3ff3272c563724f8c6d93da137de0..d00360b04ad95fd42d51d4e82e1f90fb460b1c13 100644 (file)
@@ -376,7 +376,7 @@ BeesHashTable::prefetch_loop()
                // above still fires so operators see the same content; only
                // the file write is suppressed to avoid throwing from the
                // inert BeesStringFile handle.
-               if (m_ctx->home_fd()) {
+               if (!!m_ctx->home_fd()) {
                        catch_all([&]() {
                                m_stats_file.write(graph_blob.str());
                        });