diff options
| -rw-r--r-- | src/Trivmix.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Trivmix.hs b/src/Trivmix.hs index 79b3804..96e578b 100644 --- a/src/Trivmix.hs +++ b/src/Trivmix.hs | |||
| @@ -165,7 +165,7 @@ handleFiles :: INotify -> MVar Level -> [FilePath] -> IO () | |||
| 165 | handleFiles inotify level files = do | 165 | handleFiles inotify level files = do |
| 166 | initLevel <- readMVar level | 166 | initLevel <- readMVar level |
| 167 | levelChanges <- (newChan :: IO (Chan Level)) | 167 | levelChanges <- (newChan :: IO (Chan Level)) |
| 168 | stderrLock <- newMVar | 168 | stderrLock <- newMVar) () |
| 169 | let | 169 | let |
| 170 | handleFile file = do | 170 | handleFile file = do |
| 171 | levelChanges' <- dupChan levelChanges | 171 | levelChanges' <- dupChan levelChanges |
| @@ -220,7 +220,7 @@ readLevel :: Chan Level -> MVar Level -> FilePath -> MVar () -> IO () | |||
| 220 | readLevel levelChan current file stderrLock = catch action handler | 220 | readLevel levelChan current file stderrLock = catch action handler |
| 221 | where | 221 | where |
| 222 | action = do | 222 | action = do |
| 223 | level <- withFileLock file Shared $ readFile file >>= readIO . stripSpace | 223 | level <- withFileLock file Shared $ const $ readFile file >>= readIO . stripSpace |
| 224 | oldLevel <- readMVar current | 224 | oldLevel <- readMVar current |
| 225 | when (oldLevel /= level) $ do | 225 | when (oldLevel /= level) $ do |
| 226 | writeChan levelChan level | 226 | writeChan levelChan level |
| @@ -239,7 +239,7 @@ readLevel levelChan current file stderrLock = catch action handler | |||
| 239 | else l | 239 | else l |
| 240 | 240 | ||
| 241 | writeLevel :: FilePath -> MVar () -> Level -> IO () | 241 | writeLevel :: FilePath -> MVar () -> Level -> IO () |
| 242 | writeLevel file stderrLock level = withFileLock file Exclusive $ do | 242 | writeLevel file stderrLock level = withFileLock file Exclusive $ const $ do |
| 243 | withMVarLock stderrLock $ | 243 | withMVarLock stderrLock $ |
| 244 | hPutStrLn stderr $ "Writing out level ‘" ++ (show level) ++ "’ to ‘" ++ file ++ "’" | 244 | hPutStrLn stderr $ "Writing out level ‘" ++ (show level) ++ "’ to ‘" ++ file ++ "’" |
| 245 | writeFile file (show level ++ "\n") | 245 | writeFile file (show level ++ "\n") |
