aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/populate/src/sh.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-30 18:07:34 +0000
committertv <tv@krebsco.de>2026-11-30 18:07:34 +0000
commitc8088839270c8994c0533d2fbfec7e5ade69cb57 (patch)
treea1a3f8b8570da714832faa1c61bd676892ddc58d /pkgs/populate/src/sh.rs
parentb3e1b76e2842e6b6d74789aa8b0f3ed9e2c005a0 (diff)
populate file: skip sources rsync would find nothing to do for
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.
Diffstat (limited to 'pkgs/populate/src/sh.rs')
-rw-r--r--pkgs/populate/src/sh.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkgs/populate/src/sh.rs b/pkgs/populate/src/sh.rs
index 52d41ac..f29b1f1 100644
--- a/pkgs/populate/src/sh.rs
+++ b/pkgs/populate/src/sh.rs
@@ -344,6 +344,24 @@ fi
"#
}
+/// listings PATH...: prints, for each PATH, P and PATH, an entry for each
+/// thing at and below PATH, with E, mode, size, modification time in
+/// seconds since the epoch, path relative to PATH, and symlink target,
+/// and S and find's exit status, all separated by NULs, so any path comes
+/// through. rsync::found reads it. find follows no symlinks, also not
+/// PATH itself, so a symlink at PATH shows as such.
+pub const LISTINGS: &str = r#"
+for path; do
+ printf 'P\0%s\0' "$path"
+ if find "$path" -printf 'E\0%M\0%s\0%T@\0%P\0%l\0' 2>/dev/null; then
+ status=0
+ else
+ status=$?
+ fi
+ printf 'S\0%s\0' "$status"
+done
+"#;
+
/// symlink PATH TARGET: makes PATH a symlink to TARGET, printing changed
/// if it wasn't one. What else is at PATH, e.g. the Git work tree of a
/// source that had another type, gets removed first: ln -f replaces files