Skip to content

Commit

Permalink
Merge pull request #1746 from digitallyinduced/fix-file-watcher
Browse files Browse the repository at this point in the history
Fixed putMVar blocking file watcher
  • Loading branch information
mpscholten authored Jul 15, 2023
2 parents 4e6df9a + 34134e5 commit 142c32c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions IHP/IDE/FileWatcher.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ startWatchingSubDirectory manager state path = do
Just _ -> pure ()
Nothing -> do
stop <- FS.watchTree manager path shouldActOnFileChange handleFileChange
putMVar state $ Map.insert path stop watchedDirectories
modifyMVar_ state (\map -> pure (Map.insert path stop map))

stopWatchingSubDirectory :: FileWatcherState -> FilePath -> IO ()
stopWatchingSubDirectory state path = do
watchedDirectories <- readMVar state
case Map.lookup path watchedDirectories of
Just stop -> do
stop
putMVar state $ Map.delete path watchedDirectories
modifyMVar_ state (\map -> pure (Map.delete path map))
Nothing -> pure ()

listWatchableDirectories :: IO [String]
Expand Down

0 comments on commit 142c32c

Please sign in to comment.