diff options
| author | tv <tv@krebsco.de> | 2026-12-01 02:47:32 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 04:06:17 +0000 |
| commit | 3aff9c58c68d6882294e6586ddb384709ce95abe (patch) | |
| tree | f7f7d13dec077dc21858f56a3a990c483f5f22c8 /pkgs/populate/src/populate.rs | |
| parent | cf26dc1f928e9839123bedd1693d792bbb418312 (diff) | |
populate: probe passage and pass sources too
A passage source ran rsync on every run, about a dozen round trips to a
remote target, and a pass source a command reading .pass_info, which
tells whether the passwords changed.
The probe lists the target paths of passage sources too, and reads what
pass sources' .pass_info contains. After decrypting, a passage source
lists its working directory with find, whose files have the times of
their .age files and fixed modes, and doesn't run rsync if the listings
are the same; Delivery::transfer does that for any source the probe
listed. A pass source takes .pass_info from the probe.
Diffstat (limited to 'pkgs/populate/src/populate.rs')
| -rw-r--r-- | pkgs/populate/src/populate.rs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/pkgs/populate/src/populate.rs b/pkgs/populate/src/populate.rs index 884ecd9..f8d5c0c 100644 --- a/pkgs/populate/src/populate.rs +++ b/pkgs/populate/src/populate.rs @@ -211,14 +211,16 @@ impl Delivery<'_> { } /// Transfers source_path, prepared on the deploying machine, to the - /// target path, with rsync's default configuration. + /// target path, with rsync's default configuration, unless the probe + /// listed the target path, and it has what rsync would transfer. fn transfer(&self, source_path: &Path) -> Result<Outcome> { - let changed = rsync::transfer( - self.context, - &Config::default(), - &source_path.to_string_lossy(), - self.path, - )?; + let config = Config::default(); + let listing = self.target.and_then(|target| target.listing.as_ref()); + let prepared = rsync::prepare(&config, &source_path.to_string_lossy(), listing.is_some())?; + if prepared.listing.is_some() && prepared.listing.as_ref() == listing { + return Ok(Outcome::changed(false)); + } + let changed = rsync::transfer_prepared(self.context, &config, &prepared, self.path)?; Ok(Outcome::changed(!changed.is_empty())) } } @@ -356,9 +358,10 @@ fn gathered( /// What the probe looks for at a source's target path, see probe::probe: /// the listing of a file source that's a directory, that rsync compares by -/// size and time, not checksum, the symlink of a symlink source, and the -/// work tree of a git source with a commit as ref. Not where the flakes -/// step rewrites a lock file in place, which delivering brings back. +/// size and time, not checksum, and of a passage source, the symlink of a +/// symlink source, the .pass_info of a pass source, and the work tree of a +/// git source with a commit as ref. Not where the flakes step rewrites a +/// lock file in place, which delivering brings back. fn probed(_name: &str, source: &Source) -> Option<&'static str> { if in_place_lock(source).is_some() { return None; @@ -368,6 +371,8 @@ fn probed(_name: &str, source: &Source) -> Option<&'static str> { .is_ok_and(|path| Path::new(path).is_dir() && !file_config(source, path).use_checksum) .then_some("F"), "symlink" => Some("L"), + "passage" => Some("F"), + "pass" => Some("I"), "git" => (string(&source.settings, "ref").is_ok_and(probe::is_commit) && source.settings.get("fetchAlways").and_then(Value::as_bool) != Some(true)) .then_some("G"), @@ -585,7 +590,11 @@ impl Kind for Pass { ))?; let info = info.trim_end_matches('\n'); if !info.is_empty() { - let delivered = d.context.output(sh::PASS_INFO, &[d.path])?; + // What the probe read, else a command on the target. + let delivered = match d.target.and_then(|probed| probed.info.clone()) { + Some(delivered) => delivered, + None => d.context.output(sh::PASS_INFO, &[d.path])?, + }; if delivered.trim_end_matches('\n') == info { return Ok(Outcome::changed(false)); } |
