From cf841fb258388466cadb02b19e10ec8a9ba16225 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Fri, 27 May 2011 11:20:32 +0300 Subject: [PATCH] Incomplete strict hash code --- Yesod/Static.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Yesod/Static.hs b/Yesod/Static.hs index 126506f5..78744955 100644 --- a/Yesod/Static.hs +++ b/Yesod/Static.hs @@ -238,6 +238,7 @@ mkStaticFiles' fp routeConName makeHash = do pack' <- [|pack|] qs <- if makeHash then do hash <- qRunIO $ base64md5File $ pathFromPieces fp (map pack f) + -- FIXME hash <- qRunIO . calcHash $ fp ++ '/' : intercalate "/" f [|[(pack $(lift hash), mempty)]|] else return $ ListE [] return @@ -290,3 +291,10 @@ getStaticHandler static toSubR pieces = do handler = fromMaybe notFound $ handleSite staticSite undefined route "GET" -} + +calcHash :: FilePath -> IO String +calcHash fname = + withBinaryFile fname ReadMode hashHandle + where + hashHandle h = do s <- L.hGetContents h + return $! base64md5 s