summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/daemon.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-13 15:40:34 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-13 15:40:34 +0200
commitd917bb61e42336c38782b22da604d7ca923d484a (patch)
tree3ad99072f02d621ca4a54f4fcce65a2c530c4b79 /packages/meshbay-node/src/meshbay_node/daemon.py
parentc5fff4ce8366b08669c0c8b6d30b99b94b9fefca (diff)
downloadmeshbay-d917bb61e42336c38782b22da604d7ca923d484a.tar.gz
fix(node): an uploaded file records who sent it
`_register_uploader` walked the index for the entry it had just written, at a moment when no such entry can exist: the file was a `.part` until the rename on the line above, which is not indexable, and the watchdog that will index it debounces for two seconds and then hashes. The walk matched nothing, silently, so every uploaded file in every group was owned by nobody — and `file_delete` refuses a caller with no admin authority when the entry records no uploader, so a member could not delete what they had just sent. MESHBAY_DESIGN.md §5.4 grants that to any non-revoked device of the uploading account. The record is now written when the last chunk lands (`indexer.record_upload`) and the entry is stamped from it in `_hash_or_cached`, the one funnel every entry passes through — initial scan, watchdog, reconcile and replug alike. It lives in the index cache rather than on the entry alone, because the index is rebuilt from disk at every start and an owner the node forgets on restart is a right quietly taken away. It is validated against a live `stat()`, so whatever later occupies that path inherits nothing; and `_rescan_root`'s carry-over no longer copies over it, or memory would beat the durable record. §5.4 also claimed ownership was *provable* — a transcript the uploader signs, stored with the entry. No such signature has ever existed; `meshbay:upload:v1` in the code is the groupbox purpose that seals the envelope. The section now states what the code does, and the transcript is an open item in §15.3. `test_upload_attribution.py` drives the real handler and a real indexer across that seam. Against the previous source its two positive cases fail on the property, not on a missing method — an upload, then a rebuild from disk, then a different file at the same path inheriting nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UMxEQadpzPkYLFf5CYKhpW
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/daemon.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/daemon.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py
index dcfa8f8..9428ddd 100644
--- a/packages/meshbay-node/src/meshbay_node/daemon.py
+++ b/packages/meshbay-node/src/meshbay_node/daemon.py
@@ -393,6 +393,11 @@ class NodeDaemon:
# _reconcile_loop) so the backstop is prompt again now
# that someone is actually looking.
"note_activity": indexer.note_activity,
+ # Bound method, called when an upload finishes. The entry
+ # it belongs to does not exist yet (see
+ # webrtc_server._register_uploader), so the indexer keeps
+ # the record and stamps the entry when it creates it.
+ "record_upload": indexer.record_upload,
# Shown to the operator in Settings, and kept current in
# place by set_scan_settings (ops.py) — same reasoning as
# enabled_apps below.
@@ -879,6 +884,7 @@ class NodeDaemon:
"index": indexer.index,
"progress": indexer.progress,
"note_activity": indexer.note_activity,
+ "record_upload": indexer.record_upload,
"reconcile_interval_secs": scan_settings["reconcile_interval_secs"],
"debounce_secs": scan_settings["debounce_secs"],
"visibility": group_cfg.visibility,