liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 146a2d9ac02a18cb81fafc66df165108b1792d6a
parent 091d8637108df06b11a06928984734bcd5ca66b8
Author: Daniel Barlow <dan@telent.net>
Date:   Wed,  4 Sep 2024 21:19:51 +0100

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

Diffstat:
Mpkgs/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 @@ -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) {})))))