Files
Nathaniel Ledford 0d2dd9a974 A library's files were written by path, so a path that came to lead
somewhere else (a share mounted over the folder, the folder moved away
and another put in its place) made the session write into that other
folder: its catalog.snap and catalog.log were replaced, and dropping the
lock removed the owner note of the program that had the library open.

OpenedFolder records the folder's device and inode number (and when it
was made, where the file system keeps that) when a library opens, and
check() asks, with one stat, whether the path still leads to it. A drive
or share mounted again gets another device number, and some file systems
number their folders anew at every mount, so a folder also counts when
it holds exactly the owner note this session's lock wrote (the lock
vouches for it, and the note holds a value no other lock's note has), or
when it has the same inode number and both creation times are known and
equal; on the same device two different creation times are two folders,
since an inode number is given again to a folder made later. FsStore
(both stores of a library, the snapshot worker), the catalog log's
thread and the lock's owner note ask before they write; a refusal is an
ordinary write error that names the path, so the changes stay queued,
the app says why they are unsaved, and saving goes on once the folder is
back. The thumbnail cache gets a gate that the library closes the same
way, and its takeover, prune and clear passes look at it every 256
files.

The catalog log is opened by its path for each batch and appended to
only while it is as long as what the thread wrote. A copy of the folder
put at the path holds the note and counts as the library, but its log
lacks what was written after the copy was made: it is refused like a
failed write (reported, with later changes taken meanwhile), and the
snapshot the app takes for held records replaces it, instead of going on
writing into the folder that was moved away. A longer log is cut back
only after a write of the thread's own failed.

The lock removes the owner note only when it is the one it wrote, in the
folder it locked. Reopening a path whose folder was replaced takes that
folder's own lock instead of handing the old one over, so does the
check_library preflight, and a lock taken in another folder than the
stores recorded is refused. A Move import removes its originals only
after the catalog log is on disk, not when it was handed to the log's
thread.

Windows reports no folder identity through std (nightly only): there the
check only asks that a folder is still at the path.
2026-11-07 15:32:03 -05:00
..