Skip to content

fix(nodes): display real storage usage instead of always zero#31

Closed
Nic-dorman wants to merge 1 commit intomainfrom
fix/nodes-storage-display
Closed

fix(nodes): display real storage usage instead of always zero#31
Nic-dorman wants to merge 1 commit intomainfrom
fix/nodes-storage-display

Conversation

@Nic-dorman
Copy link
Copy Markdown
Contributor

Summary

  • Per-node Storage tile always showed 0 B because we pointed at ${dataDir}/chunks.mdb — LMDB's default subdir layout makes that a directory, not a file. std::fs::metadata(dir).len() returns a trivial value on Windows and macOS, which then got clamped to zero after the old code's 16 KB "empty LMDB" subtraction.
  • Fix the path to chunks.mdb/data.mdb (the actual payload file) and route through a new get_disk_usage Tauri command that returns filesystem-allocated bytes, not logical size.

Why a new command vs reusing get_file_size

LMDB's data.mdb can be a sparse file — the logical size equals the configured map_size (tens of MB to many GB), but only a fraction is actually allocated on disk. metadata.len() would over-report. The new command uses:

  • Unix (Linux / macOS): stat.st_blocks * 512 — matches du -B1, correct for APFS / ext4 / btrfs / ZFS.
  • Windows: falls back to metadata.len(). NTFS doesn't mark LMDB data.mdb as sparse in our current ant-node config, so logical == on-disk in practice. If that changes we'll need GetCompressedFileSizeW via windows-sys — which is exactly when the upstream daemon-exposed storage API (tracked as a separate follow-up) should replace this bridge entirely.

Verified empirically

On a Mac with a node that had been running: chunks.mdb/data.mdb reports 29.5 MB, matches what the user expected stored. The old path reported directory metadata → clamped to 0.

Test plan

  • `vitest run` — all 19 tests pass
  • `cargo check` on `src-tauri` clean
  • Run a node locally and confirm the tile shows a non-zero storage value after the node starts populating chunks
  • Verify on Windows (NTFS) and Linux (ext4) — node tile updates with real usage

🤖 Generated with Claude Code

The per-node Storage field always showed 0 B because we pointed at
`${dataDir}/chunks.mdb` — LMDB's default subdir layout makes that a
directory, not a file. `std::fs::metadata(dir).len()` returns a trivial
value on Windows and macOS, which the old code then clamped to zero
after subtracting a 16 KB "empty LMDB" baseline.

Point at the actual payload file `chunks.mdb/data.mdb`, and route
through a new `get_disk_usage` Tauri command that reports on-disk bytes
allocated (not the logical file length). On Unix that's
`stat.st_blocks * 512` so a sparse LMDB map reports real
chunks-stored rather than the configured map size. On Windows the
command falls back to `metadata.len()` since NTFS doesn't mark LMDB
`data.mdb` as sparse in our current ant-node config.

Belt-and-suspenders until the upstream daemon exposes storage usage
(see project_todo_daemon_storage_api.md).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Nic-dorman
Copy link
Copy Markdown
Contributor Author

Superseded by #34 — same storage-display fix bundled with the companion storage-dir pass-through fix. Closing as duplicate.

@Nic-dorman Nic-dorman closed this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant