aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py
new file mode 100644
index 0000000..fd3184c
--- /dev/null
+++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py
@@ -0,0 +1,23 @@
+"""Blocking disk work the session hands to `off_disk`."""
+
+from pathlib import Path
+
+from meshbay_node.roots import ROOT_NOT_SERVED, RootSet, entry_abs_path
+
+
+def _locate(roots: RootSet, entry) -> tuple[Path | None, str | None]:
+ """
+ Where an entry is, and whether it is readable — or the refusal to send.
+
+ Both halves are syscalls: `resolve()` walks the path and `exists()` stats
+ it, and a stat is what *wakes* a sleeping disk. Leaving either on the event
+ loop and offloading only the read would move the stall rather than remove
+ it, and the read would then find the disk already awake. Blocking; called
+ through `off_disk`.
+ """
+ path = entry_abs_path(roots, entry)
+ if path is None:
+ return None, ROOT_NOT_SERVED
+ if not path.exists():
+ return None, "File not on disk"
+ return path, None