diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Trivmix.hs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/Trivmix.hs b/src/Trivmix.hs index ede6f67..fe592fe 100644 --- a/src/Trivmix.hs +++ b/src/Trivmix.hs | |||
@@ -140,13 +140,12 @@ handleFiles inotify level files = do | |||
140 | initLevel <- readMVar level | 140 | initLevel <- readMVar level |
141 | levelChanges <- (newChan :: IO (Chan Level)) | 141 | levelChanges <- (newChan :: IO (Chan Level)) |
142 | let | 142 | let |
143 | handleFiles' = mapM handleFile files | ||
144 | handleFile file = do | 143 | handleFile file = do |
145 | levelChanges' <- dupChan levelChanges | 144 | levelChanges' <- dupChan levelChanges |
146 | forkIO $ forever $ do -- Broadcast level changes and update all files | 145 | forkIO $ forever $ do -- Broadcast level changes and update all files |
147 | readChan levelChanges' >>= writeLevel file | 146 | readChan levelChanges' >>= writeLevel file |
148 | addWatch inotify watchedAttrs file (const $ readLevel levelChanges level file) | 147 | addWatch inotify watchedAttrs file (const $ readLevel levelChanges level file) |
149 | foldl (.) id [onStateFile f (show initLevel ++ "\n") | f <- files] $ handleFiles' | 148 | sequence [onStateFile f (show initLevel ++ "\n") handleFile f | f <- files] |
150 | forkIO $ forever $ do | 149 | forkIO $ forever $ do |
151 | readChan levelChanges >>= swapMVar level | 150 | readChan levelChanges >>= swapMVar level |
152 | return () | 151 | return () |
@@ -171,7 +170,7 @@ onStateFile file initial action = do | |||
171 | False -> removeFile file | 170 | False -> removeFile file |
172 | releaseDir = case dirExists of | 171 | releaseDir = case dirExists of |
173 | True -> return () | 172 | True -> return () |
174 | False -> removeFile directory | 173 | False -> removeDirectory directory |
175 | acquire = acquireFile | 174 | acquire = acquireFile |
176 | release = releaseFile >> releaseDir | 175 | release = releaseFile >> releaseDir |
177 | bracket_ acquire release action | 176 | bracket_ acquire release action |