Revert "anoia.svc use timeout for inotify"
This reverts commit eca8e37e7a
.
This commit is contained in:
parent
8091e207b6
commit
8fa3443923
@ -1,14 +1,13 @@
|
|||||||
(local inotify (require :inotify))
|
(local inotify (require :inotify))
|
||||||
(local { : file-exists? } (require :anoia))
|
(local { : file-exists? } (require :anoia))
|
||||||
(local { : file-type : dir &as fs } (require :anoia.fs))
|
(local { : file-type : dir &as fs } (require :anoia.fs))
|
||||||
(local ll (require :lualinux))
|
|
||||||
|
|
||||||
(fn read-line [name]
|
(fn read-line [name]
|
||||||
(with-open [f (assert (io.open name :r) (.. "can't open file " name))]
|
(with-open [f (assert (io.open name :r) (.. "can't open file " name))]
|
||||||
(f:read "*l")))
|
(f:read "*l")))
|
||||||
|
|
||||||
(fn watch-fsevents [directory-name]
|
(fn watch-fsevents [directory-name]
|
||||||
(let [handle (inotify.init { :blocking false})]
|
(let [handle (inotify.init)]
|
||||||
(handle:addwatch directory-name
|
(handle:addwatch directory-name
|
||||||
inotify.IN_CREATE
|
inotify.IN_CREATE
|
||||||
inotify.IN_MOVE
|
inotify.IN_MOVE
|
||||||
@ -40,16 +39,11 @@
|
|||||||
(coroutine.yield self)
|
(coroutine.yield self)
|
||||||
(self:wait))))
|
(self:wait))))
|
||||||
|
|
||||||
(fn read-with-timeout [watcher]
|
|
||||||
(let [fd (watcher:fileno)]
|
|
||||||
(ll.pollin fd 5000)
|
|
||||||
(watcher:read)))
|
|
||||||
|
|
||||||
(fn open [directory]
|
(fn open [directory]
|
||||||
(let [watcher (watch-fsevents directory)
|
(let [watcher (watch-fsevents directory)
|
||||||
has-file? (fn [filename] (file-exists? (.. directory "/" filename)))]
|
has-file? (fn [filename] (file-exists? (.. directory "/" filename)))]
|
||||||
{
|
{
|
||||||
:wait #(read-with-timeout watcher)
|
:wait #(watcher:read)
|
||||||
:ready? (fn [self]
|
:ready? (fn [self]
|
||||||
(and (has-file? "state") (not (has-file? ".lock"))))
|
(and (has-file? "state") (not (has-file? ".lock"))))
|
||||||
:output (fn [_ filename]
|
:output (fn [_ filename]
|
||||||
|
Loading…
Reference in New Issue
Block a user