Skip to content

fix(nodes): honour storage dir setting + show real storage usage#34

Merged
Nic-dorman merged 2 commits intomainfrom
fix/node-storage-dir-and-display
Apr 22, 2026
Merged

fix(nodes): honour storage dir setting + show real storage usage#34
Nic-dorman merged 2 commits intomainfrom
fix/node-storage-dir-and-display

Conversation

@Nic-dorman
Copy link
Copy Markdown
Contributor

@Nic-dorman Nic-dorman commented Apr 20, 2026

Closes #33

Summary

Two related node-management fixes that shipped broken:

  1. storage_dir setting was ignored. Every new node landed in the daemon's default data dir because stores/nodes.ts::addNodes never passed data_dir_path on the request, even though the setting was persisted to config.toml and ant-core's add endpoint already accepts it. Also makes it explicit in the Settings UI that the directory only applies to newly added nodes (existing nodes aren't migrated). As a small follow-on, addNodes now fires enrichNodeDetails right after the add so the node tile shows its data_dir without needing a refresh.

  2. Per-node Storage field always read 0 B. We were pointing get_file_size at chunks.mdb, which under LMDB's default layout is a directory, not a file — metadata.len() on a directory returns a trivial value that the old baseline subtraction clamped to zero. We now read chunks.mdb/data.mdb via a new get_disk_usage Tauri command that reports the filesystem-allocated bytes (sparse-aware on Unix, metadata.len() on Windows).

Supersedes #31 — this branch contains the same storage-display fix plus the storage-dir fix on top. Please merge this and close #31 as duplicate.

Test plan

  • Settings → Storage Directory shows the "only applies to newly added nodes" warning.
  • After changing the storage dir and adding a node, the new node's data_dir lives under <new-dir>/node-<id>/ (verified on local release build).
  • Node tile's Storage field reports non-zero (baseline 8 KB on empty LMDB; grows once chunks land — awaiting first chunks to visually confirm growth, but the on-disk value is correct).
  • Once upstream daemon exposes storage via its status endpoint (see project_todo_daemon_storage_api.md), drop the on-disk workaround.

🤖 Generated with Claude Code

Nic-dorman and others added 2 commits April 20, 2026 10:09
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>
The "Storage Directory" setting was persisted to config.toml but never
sent to the daemon on add_nodes, so every new node landed in the
default data directory regardless of the user's choice. ant-core's
add_nodes endpoint already supports data_dir_path and auto-appends
node-{id} per node, so we just need to pass it through.

Also clarifies in Settings that the directory only affects newly
added nodes — existing nodes keep their original data_dir in
node_registry.json and are not migrated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Nic-dorman Nic-dorman merged commit 1a9f271 into main Apr 22, 2026
4 checks passed
@Nic-dorman Nic-dorman deleted the fix/node-storage-dir-and-display branch April 22, 2026 11:44
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.

Changing node directory doesnt change where nodes are installed

1 participant