@@ -15,8 +15,12 @@ import Network.Wai.Handler.Warp.SendFile (positionRead)
1515
1616pReadMaker :: InternalInfo -> PositionReadMaker
1717pReadMaker ii path = do
18− (Just fd, refresh) <- getFd ii path
19− return (pread fd, Refresher refresh)
18+ (mfd, refresh) <- getFd ii path
19+ case mfd of
20+ Just fd -> return (pread fd, Refresher refresh)
21+ Nothing -> do
22+ fd <- openFile path
23+ return (pread fd, Closer $ closeFile fd)
2024 where
2125 pread :: Fd -> PositionRead
2226 pread fd off bytes buf = fromIntegral <$> positionRead fd buf bytes' off'