1
0

service outputs falls back to properties (untested)

This commit is contained in:
Daniel Barlow 2025-03-18 18:38:04 +00:00
parent 4e51977ae0
commit be03e9e8c8

View File

@ -51,16 +51,21 @@
(fn open [directory] (fn open [directory]
(let [watcher (watch-fsevents directory) (let [watcher (watch-fsevents directory)
has-file? #(file-exists? (append-path directory $1)) has-file? #(file-exists? (append-path directory $1))
outputs-dir (append-path directory ".outputs")] outputs-dir (append-path directory ".outputs")
properties-dir (append-path directory ".properties")]
{ {
:wait #(watcher:read) :wait #(watcher:read)
:ready? (fn [self] :ready? (fn [self]
(and (has-file? ".outputs/state") (and (has-file? ".outputs/state")
(not (has-file? ".outputs/.lock")))) (not (has-file? ".outputs/.lock"))))
:output (fn [_ filename new-value] :property (fn [_ filename]
(read-value (append-path properties-dir filename)))
:output (fn [filename new-value]
(if new-value (if new-value
(write-value (append-path outputs-dir filename) new-value) (write-value (append-path outputs-dir filename) new-value)
(read-value (append-path outputs-dir filename)))) (or
(read-value (append-path outputs-dir filename))
(read-value (append-path properties-dir filename)))))
:close #(watcher:close) :close #(watcher:close)
:fileno #(watcher:fileno) :fileno #(watcher:fileno)
: events : events