fix: use absolute dir path for watcher makeRelative consistency

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