Skip to content

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

Merged
Nic-dorman merged 2 commits into
mainfrom
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 into
mainfrom
fix/node-storage-dir-and-display

Conversation

@Nic-dorman

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

Copy link
Copy Markdown
Contributor

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
Nic-dorman added a commit that referenced this pull request May 14, 2026
Two related fixes for the customer-reported Windows toast:

  Failed to add nodes: {"error":"I/O error: Access is denied. (os error 5)"}

The PR #34 release (v0.6.7) was the first build where storage_dir is
actually honored at node-add time — any path that's writable in
Explorer but not to the daemon process (USB read-only volume, OneDrive
placeholder, second-drive default ACL, network share) now produces this
error. The toast also shows the daemon's raw JSON envelope verbatim,
which looks broken even when the underlying error is real.

Three defences:

1. probe_writable Tauri command — writes a tiny sentinel, fsyncs,
   deletes. Surfaces the raw OS message + path on failure.

2. Settings → Storage Directory picker calls probe_writable before
   persisting. On failure, the path is not saved and the error is
   surfaced both inline under the card and as a global banner in the
   default layout. Toast on success is "Storage directory verified"
   instead of the previous unconditional "Storage directory updated".

3. Startup re-probe — app.vue calls settingsStore.revalidateStorageDir()
   after loadConfig so a previously-working path that's gone offline
   (USB unplugged, OneDrive offline, perms changed) is caught before
   the user reaches Add Node. Non-blocking; does not clear the saved
   path.

4. daemon-api request() unwraps the {"error": "..."} envelope from
   4xx/5xx bodies, falling back to the raw body when it isn't JSON or
   doesn't have the expected shape. Covers every daemon error toast in
   the app, not just addNodes.

Tests: 5 cases for the envelope unwrap (JSON envelope, plain string,
unrelated JSON shape, malformed JSON, Error instance with .message).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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