On this page:
share-entry
share-state
share-state-ok?
mapped-drive-status
share-reachable?
share-directory-snapshot
start-share-watcher
share-watcher?
share-watcher-state
share-watcher-stop!

7 Network Shares🔗ℹ

 (require rivet/share-watch) package: rivet

On Windows, a filesystem call that parks on a mapped-but-disconnected SMB share blocks the single OS thread that runs every Racket thread, freezing the engine and every RPC. Reachability therefore comes from the redirector’s state table (parameterless net use), and directory scans run in a place so a stalled share can stall only the worker.

struct

(struct share-entry (name path directory? size modify-seconds))

  name : string?
  path : path?
  directory? : boolean?
  size : exact-nonnegative-integer?
  modify-seconds : exact-nonnegative-integer?
One entry returned by share-directory-snapshot.

struct

(struct share-state (status entries))

  status : symbol?
  entries : (vectorof share-entry?)
The result of a share scan. The status is 'ok, 'unreachable, 'missing, 'timeout, 'unsupported, or 'error.

procedure

(share-state-ok? state) → boolean?

  state : share-state?
Returns true when the scan succeeded.

procedure

(mapped-drive-status path) → symbol?

  path : path-string?
Returns the redirector status for the drive containing path: 'ok, 'reconnecting, 'unavailable, 'disconnected, 'connecting, 'other, 'not-mapped, or 'unknown for a UNC path. The probe reads the local state table and never opens the share.

procedure

(share-reachable? path) → boolean?

  path : path-string?
Returns true for a healthy mapped drive, a local path, and a UNC path whose reachability is decided by the scan timeout.

procedure

(share-directory-snapshot path    
  [#:timeout timeout]) → share-state?
  path : path-string?
  timeout : real? = 5.0
Lists path in a worker place and waits at most timeout seconds. A timeout kills the worker and returns 'timeout; a mapped drive whose state is not 'ok returns 'unreachable without touching the share.

procedure

(start-share-watcher path    
  [#:interval interval    
  #:timeout timeout    
  #:on-change on-change]) → share-watcher?
  path : path-string?
  interval : real? = 5.0
  timeout : real? = 5.0
  on-change : (-> share-state? any/c) = void
Polls path and calls on-change whenever the status or the entry set changes. The first callback carries the initial state.

procedure

(share-watcher? value) → boolean?

  value : any/c
Recognizes a running or stopped share watcher.

procedure

(share-watcher-state watcher) → share-state?

  watcher : share-watcher?
Returns the most recent scan state.

procedure

(share-watcher-stop! watcher) → void?

  watcher : share-watcher?
Stops the watcher thread. Safe to call from its own callback.