From 240b8776f04a37afe485323ce00d3f2ceda7afb5 Mon Sep 17 00:00:00 2001 From: Mario Rogic Date: Mon, 22 Jan 2024 08:40:57 +1100 Subject: [PATCH] Fix silly elm-pages check bug --- ext-elm-pages/Ext/ElmPages.hs | 2 +- ext-sentry/Ext/Filewatch.hs | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ext-elm-pages/Ext/ElmPages.hs b/ext-elm-pages/Ext/ElmPages.hs index e6491e1b..a7ef901e 100644 --- a/ext-elm-pages/Ext/ElmPages.hs +++ b/ext-elm-pages/Ext/ElmPages.hs @@ -32,7 +32,7 @@ isElmPages = do {-# NOINLINE isElmPages_ #-} isElmPages_ :: Bool -isElmPages_ = unsafePerformIO $ isDebug +isElmPages_ = unsafePerformIO $ isElmPages diff --git a/ext-sentry/Ext/Filewatch.hs b/ext-sentry/Ext/Filewatch.hs index 8def850d..8a83316c 100644 --- a/ext-sentry/Ext/Filewatch.hs +++ b/ext-sentry/Ext/Filewatch.hs @@ -3,7 +3,7 @@ module Ext.Filewatch where import Ext.Common -import System.FSNotify +import qualified System.FSNotify as FSNotify import Control.Concurrent (threadDelay) import Control.Monad (forever) import qualified Data.List as List @@ -12,8 +12,10 @@ import qualified System.FilePath as FP watch :: FilePath -> ([FilePath] -> IO ()) -> IO () -watch root action = - trackedForkIO "Ext.Filewatch.watch" $ withManager $ \mgr -> do +watch root action = do + let config = FSNotify.defaultConfig { FSNotify.confOnHandlerException = \e -> Ext.Common.debug ("fsnotify: handler threw exception: " <> show e) } + + trackedForkIO "Ext.Filewatch.watch" $ FSNotify.withManagerConf config $ \mgr -> do trigger <- Debounce.new Debounce.Args @@ -28,20 +30,20 @@ watch root action = Ext.Common.debug $ "👀 file watch booting for " ++ show root -- start a watching job (in the background) - _ <- watchTree + _ <- FSNotify.watchTree mgr -- manager root -- directory to watch (const True) -- predicate (\e -> do let filepath = case e of - Added f _ _ -> f - Modified f _ _ -> f - ModifiedAttributes f _ _ -> f - Removed f _ _ -> f - WatchedDirectoryRemoved f _ _ -> f - CloseWrite f _ _ -> f - Unknown f _ _ _ -> f + FSNotify.Added f _ _ -> f + FSNotify.Modified f _ _ -> f + FSNotify.ModifiedAttributes f _ _ -> f + FSNotify.Removed f _ _ -> f + FSNotify.WatchedDirectoryRemoved f _ _ -> f + FSNotify.CloseWrite f _ _ -> f + FSNotify.Unknown f _ _ _ -> f -- @TODO it would be better to not listen to these folders in the `watchTree` when available -- https://github.com/haskell-fswatch/hfsnotify/issues/101