blob: fd3184cb676232cf7eda09184dee786e962e76ff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
|