From 7216c1779a799652a8fb4d9301bbf05952b33661 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Thu, 24 Sep 2026 01:44:17 +0200 Subject: refactor(node): move the subtitle handler out of webrtc_server SubtitlesMixin in transport/webrtc/apps/subtitles.py; _locate, which it shares with the files, music and streaming handlers, in webrtc/disk.py. Co-Authored-By: Claude Opus 5.5 --- .../src/meshbay_node/transport/webrtc/disk.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py (limited to 'packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py') 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 -- cgit v1.2.3