Skip to main content

Module platform

Module platform 

Source
Expand description

Small platform differences that the rest of the code should not have to know about.

  • replace_file: the “write a temp file, rename it over the target” step. On Windows a rename over a file another process has open (an antivirus scan, a backup agent, a reader) fails with a sharing violation that clears within moments, so it is retried a bounded number of times.
  • network_fs: whether a path is on a network filesystem. SQLite’s WAL mode needs shared memory and locks that NFS and SMB do not provide reliably, so a vault there can corrupt; unv doctor says so instead of letting it happen quietly.

Functions§

is_unc
A Windows UNC path (\\server\share\...), which is always a network location.
network_fs
The name of the network filesystem path lives on, or None when it is local or unknown.
parse_mount_output
The same for the output of mount on macOS: host:/export on /Volumes/x (nfs, nodev, ...).
parse_proc_mounts
The filesystem type of the longest mount point that contains path, from /proc/mounts text.
replace_file
Renames from over to. On Windows a sharing violation is retried briefly; elsewhere this is a plain rename, which is already atomic.
retry
Runs op, repeating up to ATTEMPTS times while transient says the error will pass.