From 146a2d9ac02a18cb81fafc66df165108b1792d6a Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Wed, 4 Sep 2024 21:19:51 +0100 Subject: [PATCH] fix startup race/fencepost in watch-ssh-keys if it starts _after_ the outputs are populated, it should write the first lot of outputs without waiting for a change --- pkgs/watch-ssh-keys/watch-ssh-keys.fnl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/watch-ssh-keys/watch-ssh-keys.fnl b/pkgs/watch-ssh-keys/watch-ssh-keys.fnl index e123843..3e8439c 100644 --- a/pkgs/watch-ssh-keys/watch-ssh-keys.fnl +++ b/pkgs/watch-ssh-keys/watch-ssh-keys.fnl @@ -11,6 +11,7 @@ (fn write-changes [path old-tree new-tree] (when (not (table= old-tree new-tree)) + (io.stderr:write "new ssh keys\n") (each [username pubkeys (pairs new-tree)] (with-open [f (assert (io.open (.. path "/" username) :w))] ;; the keys are "1" "2" "3" etc, so pairs not ipairs @@ -47,12 +48,11 @@ (os.remove out-dir) )) - (fn run [] (let [{: out-path : watched-service : path } (parse-args arg) dir (.. watched-service "/.outputs") service (assert (svc.open dir))] - (accumulate [tree (or (service:output path) {}) + (accumulate [tree {} v (service:events)] (write-changes out-path tree (or (service:output path) {})))))