on master help sign in
exporting FileInfoCache module from Internal.
commit0175a2029ac162198de191d38f9c1dd5f3afba26 authorKazu Yamamoto <kazu@iij.ad.jp> dateTue 1 Dec 2015, 14:14 (11 years ago) parentc752eed
2 files changed+8−2
warp/Network/Wai/Handler/Warp/FileInfoCache.hs+5−2 warp/Network/Wai/Handler/Warp/Internal.hs+3
warp/Network/Wai/Handler/Warp/FileInfoCache.hs+5−2
@@ -1,9 +1,7 @@
11{-# LANGUAGE RecordWildCards, CPP #-}
22
33module Network.Wai.Handler.Warp.FileInfoCache (
4− -- * Types
54 FileInfo(..)
6− -- * Functions
75 , withFileInfoCache
86 , getInfo -- test purpose only
97 ) where
@@ -24,6 +22,7 @@ import Network.Wai.Handler.Warp.Date (uToH)
2422
2523----------------------------------------------------------------
2624
25+-- | File information.
2726data FileInfo = FileInfo {
2827 fileInfoName :: !FilePath
2928 , fileInfoSize :: !Integer
@@ -37,6 +36,7 @@ type FileInfoCache = Reaper Cache (FilePath,Entry)
3736
3837----------------------------------------------------------------
3938
39+-- | Getting the file information corresponding to the file.
4040getInfo :: FilePath -> IO FileInfo
4141getInfo path = do
4242 fs <- getFileStatus path -- file access
@@ -79,6 +79,9 @@ negative Reaper{..} path = do
7979
8080----------------------------------------------------------------
8181
82+-- | Creating a file information cache
83+-- and executing the action in the second argument.
84+-- The first argument is a cache duration in second.
8285withFileInfoCache :: Int -> ((FilePath -> IO FileInfo) -> IO a) -> IO a
8386withFileInfoCache 0 action = action getInfo
8487withFileInfoCache duration action = E.bracket (initialize duration)
warp/Network/Wai/Handler/Warp/Internal.hs+3
@@ -67,6 +67,8 @@ module Network.Wai.Handler.Warp.Internal (
6767 , module Network.Wai.Handler.Warp.Timeout
6868 -- * File descriptor cache
6969 , module Network.Wai.Handler.Warp.FdCache
70+ -- * File information cache
71+ , module Network.Wai.Handler.Warp.FileInfoCache
7072 -- * Date
7173 , module Network.Wai.Handler.Warp.Date
7274 -- * Request and response
@@ -78,6 +80,7 @@ module Network.Wai.Handler.Warp.Internal (
7880import Network.Wai.Handler.Warp.Buffer
7981import Network.Wai.Handler.Warp.Date
8082import Network.Wai.Handler.Warp.FdCache
83+import Network.Wai.Handler.Warp.FileInfoCache
8184import Network.Wai.Handler.Warp.Header
8285import Network.Wai.Handler.Warp.Recv
8386import Network.Wai.Handler.Warp.Request