aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
index 29d6e7f..8df88d8 100644
--- a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
+++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
@@ -4914,26 +4914,29 @@ class WebRTCPeerSession:
log.info("Upload complete: %s (%d chunks, %d bytes)",
stored_name, total_chunks, state.bytes)
self._audit("file_upload", f"{rel_dir}/{stored_name}")
- self._register_uploader(ctx, rel_dir, stored_name)
+ self._register_uploader(ctx, final_path)
- def _register_uploader(self, ctx: dict, rel_dir: str, filename: str) -> None:
+ def _register_uploader(self, ctx: dict, file_path: Path) -> None:
"""
- Tag the index entry with the uploader's identity after upload completes.
+ Record who sent this file, for the index entry that does not exist yet.
- The key recorded here is the one this node pinned, not the one the token
+ The key recorded is the one this node pinned, not the one the token
carried. `pk_user` was a hub-chosen claim, and it decided who could later
delete the file: a hub issuing a token naming its own key could delete
anyone's uploads on any node. Deletion is supposed to be authorized by the
node, and this closes the last place where it was not.
+
+ **The entry is not here to be tagged.** This used to walk `ctx["index"]`
+ for the name just written and set the fields on it; at this point the
+ watchdog has not fired (it debounces for two seconds and then hashes)
+ and the file was a `.part` until the line above, which is not indexable
+ — so the walk matched nothing, every time, and said nothing about it.
+ The indexer stamps the entry from this record when it creates it.
"""
- idx = ctx.get("index")
- if not idx:
+ record = ctx.get("record_upload")
+ if record is None:
return
- for entry in idx.entries:
- if entry.name == filename and entry.path == rel_dir:
- entry.uploader_id = self._user_id
- entry.uploader_pk = self._pinned_pk
- return
+ self._spawn(record(file_path, self._user_id or "", self._pinned_pk or ""))
def _do_file_delete(self, msg: dict) -> None:
ctx = self._group_ctx()