fix: use absolute dir path for watcher makeRelative consistency
This commit is contained in:
+4
-2
@@ -23,7 +23,7 @@ import Data.Text (Text)
|
||||
import Data.Time.Clock (UTCTime, diffUTCTime, getCurrentTime)
|
||||
import qualified Network.HTTP.Types as HTTP
|
||||
import qualified Network.Wai as Wai
|
||||
import System.Directory (doesFileExist)
|
||||
import System.Directory (doesFileExist, makeAbsolute)
|
||||
import System.FSNotify (
|
||||
Event (..),
|
||||
EventIsDirectory (..),
|
||||
@@ -56,10 +56,12 @@ app recipeDir = do
|
||||
-- Build initial map keyed by lowercased filename (without .cook extension)
|
||||
let recipeMap = Map.fromList [(map toLower (stripCookExt (Idx.riFilename r)), r) | r <- recipes]
|
||||
state <- newIORef recipeMap
|
||||
-- Resolve to absolute path so makeRelative works with fsnotify events
|
||||
absDir <- makeAbsolute recipeDir
|
||||
-- Start the filesystem watcher
|
||||
_ <-
|
||||
forkIO $
|
||||
watchRecipes recipeDir state `catch` \e ->
|
||||
watchRecipes absDir state `catch` \e ->
|
||||
putStrLn $ "[roux] watcher thread crashed: " <> show (e :: SomeException)
|
||||
pure (handleRequest state)
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user