wai-app-static 0.3.0 → 0.3.1.1
raw patch · 2 files changed
+25/−16 lines, 2 filesdep ~timePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: time
API changes (from Hackage documentation)
+ Network.Wai.Application.Static: fileSystemLookupHash :: (FilePath -> Maybe (IO ByteString)) -> FilePath -> Pieces -> IO FileLookup
Files
- Network/Wai/Application/Static.hs +21/−12
- wai-app-static.cabal +4/−4
Network/Wai/Application/Static.hs view
@@ -33,6 +33,7 @@ , defaultListing -- ** Lookup functions , fileSystemLookup+ , fileSystemLookupHash , embeddedLookup -- ** Embedded , Embedded@@ -253,7 +254,7 @@ -> Pieces -- ^ parsed request -> W.Request -> MaxAge- -> Bool+ -> Bool -- ^ use hash? -> IO CheckPieces checkPieces fileLookup indices pieces req maxAge useHash | any unsafe pieces = return Forbidden@@ -421,27 +422,35 @@ , ssUseHash = False } -fileHelper :: FilePath -> FilePath -> IO File-fileHelper fp name = do+fileHelper :: (FilePath -> Maybe (IO ByteString)) -- ^ hash function+ -> FilePath -> FilePath -> IO File+fileHelper hashFunc fp name = do fs <- getFileStatus $ fromFilePath fp return File { fileGetSize = fromIntegral $ fileSize fs , fileToResponse = \s h -> W.ResponseFile s h (fromFilePath fp) Nothing , fileName = name- , fileGetHash = Just $ do- -- FIXME replace lazy IO with enumerators- -- FIXME let's use a dictionary to cache these values?- l <- L.readFile $ fromFilePath fp- return $ runHashL l+ , fileGetHash = hashFunc fp , fileGetModified = Just $ modificationTime fs } +defaultFileSystemHash :: FilePath -> Maybe (IO ByteString)+defaultFileSystemHash fp = Just $ do+ -- FIXME replace lazy IO with enumerators+ -- FIXME let's use a dictionary to cache these values?+ l <- L.readFile $ fromFilePath fp+ return $ runHashL l+ fileSystemLookup :: FilePath -> Pieces -> IO FileLookup-fileSystemLookup prefix pieces = do+fileSystemLookup = fileSystemLookupHash defaultFileSystemHash++fileSystemLookupHash :: (FilePath -> Maybe (IO ByteString)) -- ^ hash function+ -> FilePath -> Pieces -> IO FileLookup+fileSystemLookupHash hashFunc prefix pieces = do let fp = pathFromPieces prefix pieces fe <- doesFileExist $ fromFilePath fp if fe- then fmap (Just . Right) $ fileHelper fp $ last pieces+ then fmap (Just . Right) $ fileHelper hashFunc fp $ last pieces else do de <- doesDirectoryExist $ fromFilePath fp if de@@ -454,9 +463,9 @@ let fp' = fp </> name fe' <- doesFileExist $ fromFilePath fp' if fe'- then fmap Right $ fileHelper fp' name+ then fmap Right $ fileHelper hashFunc fp' name else return $ Left $ Folder name [])- return $ Just $ Left $ Folder (error "413") entries+ return $ Just $ Left $ Folder (error "Network.Wai.Application.Static.fileSystemLookup") entries else return Nothing type Embedded = Map.Map FilePath EmbeddedEntry
wai-app-static.cabal view
@@ -1,5 +1,5 @@ name: wai-app-static-version: 0.3.0+version: 0.3.1.1 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -10,7 +10,7 @@ stability: Stable cabal-version: >= 1.8 build-type: Simple-homepage: http://www.yesodweb.com/+homepage: http://www.yesodweb.com/book/wai Extra-source-files: folder.png, haskell.png Flag print@@ -27,7 +27,7 @@ , directory >= 1.0 && < 1.2 , containers >= 0.2 && < 0.5 , blaze-html >= 0.4 && < 0.5- , time >= 1.1.4 && < 1.3+ , time >= 1.1.4 && < 1.4 , old-locale >= 1.0.0.2 && < 1.1 , file-embed >= 0.0.3.1 && < 0.1 , text >= 0.5 && < 1.0@@ -68,4 +68,4 @@ source-repository head type: git- location: git://github.com/snoyberg/wai-app-static.git+ location: git://github.com/yesodweb/wai.git