diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-09 23:26:23 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-09 23:26:54 +0200 |
commit | df6d2563bae3a20b9db1016c4ec2ac3cb0022790 (patch) | |
tree | 5afe534dfb8a1724c84efe22330716002b2e395f /src | |
parent | a6a7d98ea56410e97f867730e90c6dd208a7eff3 (diff) | |
download | trivmix-df6d2563bae3a20b9db1016c4ec2ac3cb0022790.tar trivmix-df6d2563bae3a20b9db1016c4ec2ac3cb0022790.tar.gz trivmix-df6d2563bae3a20b9db1016c4ec2ac3cb0022790.tar.bz2 trivmix-df6d2563bae3a20b9db1016c4ec2ac3cb0022790.tar.xz trivmix-df6d2563bae3a20b9db1016c4ec2ac3cb0022790.zip |
moved file management to the proper place
Diffstat (limited to 'src')
-rw-r--r-- | src/Trivmix.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Trivmix.hs b/src/Trivmix.hs index 5dc213c..69fcea2 100644 --- a/src/Trivmix.hs +++ b/src/Trivmix.hs | |||
@@ -115,7 +115,8 @@ main = execParser opts >>= trivmix | |||
115 | trivmix :: Options -> IO () | 115 | trivmix :: Options -> IO () |
116 | trivmix Options{..} = do | 116 | trivmix Options{..} = do |
117 | level <- newMVar initialLevel | 117 | level <- newMVar initialLevel |
118 | withINotify $ \inotify -> do | 118 | let withFiles = foldl (.) id $ map (\f -> onStateFile f (show initialLevel ++ "\n")) levelFiles |
119 | withFiles $ withINotify $ \inotify -> do | ||
119 | handleFiles inotify level levelFiles | 120 | handleFiles inotify level levelFiles |
120 | Jack.handleExceptions $ | 121 | Jack.handleExceptions $ |
121 | Jack.withClientDefault client $ \client' -> | 122 | Jack.withClientDefault client $ \client' -> |
@@ -148,7 +149,7 @@ handleFiles inotify level files = do | |||
148 | forkIO $ forever $ do -- Broadcast level changes and update all files | 149 | forkIO $ forever $ do -- Broadcast level changes and update all files |
149 | readChan levelChanges' >>= writeLevel file | 150 | readChan levelChanges' >>= writeLevel file |
150 | addWatch inotify watchedAttrs file (const $ readLevel levelChanges level file) | 151 | addWatch inotify watchedAttrs file (const $ readLevel levelChanges level file) |
151 | sequence [onStateFile f (show initLevel ++ "\n") $ handleFile f | f <- files] | 152 | mapM handleFile files |
152 | forkIO $ forever $ do | 153 | forkIO $ forever $ do |
153 | readChan levelChanges >>= swapMVar level | 154 | readChan levelChanges >>= swapMVar level |
154 | return () | 155 | return () |