Skip to main content

spawn_watcher

Function spawn_watcher 

Source
pub fn spawn_watcher(
    opts: WatchOptions,
    writer: Arc<Mutex<EventWriter>>,
    blobs: Arc<BlobStore>,
    session_id: String,
    start: Instant,
) -> Result<Option<WatcherHandle>>
Expand description

Spawn the watcher thread. Returns Ok(Some(handle)) on success and Ok(None) when filesystem watching could not be set up at all — the matcher could not be built, the notify watcher could not initialize, or even the cwd itself is unwatchable. In every one of those cases the recorder does not abort: it prints a single actionable stderr warning and continues without file-change recording (FR-1.5 best-effort: PTY + adapter capture proceed regardless). Only a failure to spawn the worker thread returns Err (a fatal OS-resource error).

A single recursive watch is tried first. If it fails — e.g. one unreadable subdir (EACCES on /tmp/systemd-private-*) makes notify reject the whole recursive call — we fall back to per-directory non-recursive watches, skipping unreadable and ignored directories, so one bad subtree no longer blacks out file recording for the entire session.

start is the session-start Instant used to compute event timestamps relative to session start (FR-1.3).