]> git.hungrycats.org Git - bees/commitdiff
beesd: create beeshash.dat at full size, not zero-length
authorZygo Blaxell <bees@furryterror.org>
Fri, 26 Jun 2026 16:54:01 +0000 (12:54 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 5 Sep 2026 04:03:57 +0000 (00:03 -0400)
bees rejects a zero-length beeshash.dat: BeesHashTable::open_file() opens
the existing file and throws on the new_size > 0 check before any resize
can run.  A recent change replaced beesd's "truncate -s $DB_SIZE" with a
bare "touch", delegating sizing to bees's native state.hash.resize.  That
left a fresh install creating an empty hash table that bees cannot open,
so beesd (under both systemd and OpenRC) failed on first start.

Restore beesd's responsibility for creating the hash table at a valid
size: truncate the file to DB_SIZE when it does not exist.  An existing
file is still left untouched, so bees's native resize continues to handle
DB_SIZE changes while preserving hash contents.  DB_SIZE is validated as a
128 KiB multiple before the file is created.

Assisted-by: Claude-Code:claude-opus-4-8
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
scripts/beesd.in

index 8d22752cceb12e9b5b57b3e1e61eec7f2745c716..106f41a0ecbe1f7f49e3fab8f4b347aad19a7aa6 100755 (executable)
@@ -149,15 +149,19 @@ if [ ! -d "$BEESHOME_PATH" ]; then
     fi
 fi
 
-# Check DB size
+# Create the hash table at a valid size when it does not yet exist.  bees
+# rejects a zero-length beeshash.dat, so the file must be created at its
+# full size here, not merely touched.  An existing file is left untouched so
+# that bees's native resize (-o state.hash.resize=yes, below) can preserve
+# its contents when DB_SIZE changes.
 {
     DB_PATH="$BEESHOME_PATH/beeshash.dat"
-    if [ ! -f "$DB_PATH" ]; then
-        touch "$DB_PATH"
-    fi
     if (( "$DB_SIZE"%AL128K > 0 )); then
         ERRO "DB_SIZE Must be multiple of 128K"
     fi
+    if [ ! -f "$DB_PATH" ]; then
+        truncate -s "$DB_SIZE" "$DB_PATH"
+    fi
     chmod 700 "$DB_PATH"
 }