| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Each rsync run costs several round trips to the target, and about 45 ms
of rsync waiting for its own processes, also with nothing to transfer, so
a run with many file sources and nothing to change took long: 25.5 s for
the bench's 50 file, 30 symlink, and 20 git sources with 30 ms to the
target, 20 s of that waiting for round trips.
Right after taking the lock, one command lists the target paths of the
file sources that are directories, compared by size and time, and whose
lock file the flakes step doesn't rewrite, with find. At its turn, each
such source lists what rsync would transfer: with find, if nothing
excludes or filters anything, else with rsync --list-only, which is also
the run checking the .rsync-filter files, instead of a dry run. If both
listings have the same entries, with mode and path, and for files size and
time in whole seconds, and for symlinks the target, which is what rsync's
quick check compares, neither break_hard_links nor rsync runs. Entries
populate can't compare (paths with control characters, devices), and
sources that need --insecure-links, run rsync.
The scenario file-skip checks that an unchanged source keeps another hard
link of a file, which break_hard_links would break, and that a file too
many, a file's time, a directory's mode, and an excluded file make the
sources deliver again.
|
|
|
For consumers of the target directory on the target, e.g. a CI service,
which should act after a run that delivered everything, and know what it
delivered.
Populate holds an exclusive flock on .populate/lock from right after
checking the sentinel until it's done. The command holding it runs over
the shared connection, or directly, keeping the lock until its input
ends, which populate's ending ends as well, so no lock stays behind.
Runs wait for each other, and for consumers holding a shared lock,
saying so. The sentinel is a directory, which a sentinel file becomes,
since there's always state to keep now, and the target needs flock.
Populate keeps a journal in .populate/journal, a line of JSON for each
entry: a run starting, beginning to deliver or change a source, what
that changed, and pruning. The entries go with the next command on the
target, before what that changes, so the journal needs no commands of
its own. After delivering everything, populate replaces
.populate/run.json with the record of the run, which sums up the
journal, and removes the journal. A run that doesn't finish leaves it,
so changed in the record means changed since the last record: a source
the journal tells began changing, without what it changed, counts as
changed. The record has, for each source, its type, whether it changed,
and what got delivered: the commit of a git source, the store path of a
flake, flake-input, or derivation source, and the derived one, and a
symlink's target. Nothing about secrets, nor files.
Each source type is a Kind, whose deliver returns the Outcome: whether
anything changed, and what got delivered. rsync tells changes by what
it itemizes, the snippets by printing changed: the git source if it
cloned, reset, or submodule updates or cleaning printed anything, links
if they point elsewhere, and lock files and generated flakes if they
differ. Symlinks in place of the lock or the journal get refused.
A file or git source whose lock file populate rewrites in place counts
as changed on every run, since delivering it brings back the original.
|