Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade directory package dependency to 1.2 #327

Merged
merged 1 commit into from Nov 5, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Network/Gitit/Cache.hs
Expand Up @@ -27,7 +27,7 @@ where
import qualified Data.ByteString as B (ByteString, readFile, writeFile)
import System.FilePath
import System.Directory (doesFileExist, removeFile, createDirectoryIfMissing, getModificationTime)
import System.Time (ClockTime)
import Data.Time.Clock (UTCTime)
import Network.Gitit.State
import Network.Gitit.Types
import Control.Monad
Expand All @@ -53,7 +53,7 @@ expireCachedPDF file =
exists <- doesFileExist pdfname
when exists $ removeFile pdfname

lookupCache :: String -> GititServerPart (Maybe (ClockTime, B.ByteString))
lookupCache :: String -> GititServerPart (Maybe (UTCTime, B.ByteString))
lookupCache file = do
cfg <- getConfig
let target = encodeString $ cacheDir cfg </> file
Expand Down
12 changes: 5 additions & 7 deletions Network/Gitit/Handlers.hs
Expand Up @@ -64,7 +64,6 @@ import Network.Gitit.ContentTransformer (showRawPage, showFileAsText, showPage,
exportPage, showHighlightedSource, preview, applyPreCommitPlugins)
import Network.Gitit.Page (readCategories)
import Control.Exception (throwIO, catch, try)
import System.Time
import System.FilePath
import Prelude hiding (catch)
import Network.Gitit.State
Expand All @@ -78,7 +77,7 @@ import Control.Monad.Reader
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString as S
import Network.HTTP (urlEncodeVars)
import Data.Time (getCurrentTime, addUTCTime)
import Data.Time.Clock
import Data.FileStore
import System.Log.Logger (logM, Priority(..))

Expand Down Expand Up @@ -117,9 +116,9 @@ randomPage = do
if null pages
then error "No pages found!"
else do
TOD _ picosecs <- liftIO getClockTime
secs <- liftIO (fmap utctDayTime getCurrentTime)
let newPage = pages !!
((fromIntegral picosecs `div` 1000000) `mod` length pages)
(truncate (secs * 1000000) `mod` length pages)
seeOther (base' ++ urlForPage newPage) $ toResponse $
p << "Redirecting to a random page"

Expand Down Expand Up @@ -769,9 +768,8 @@ feedHandler = do
let file = (path' `orIfNull` "_site") <.> "feed"
let mbPath = if null path' then Nothing else Just path'
-- first, check for a cached version that is recent enough
now <- liftIO $ getClockTime
let isRecentEnough t = normalizeTimeDiff (diffClockTimes now t) <
normalizeTimeDiff (noTimeDiff{tdMin = fromIntegral $ feedRefreshTime cfg})
now <- liftIO $ getCurrentTime
let isRecentEnough t = truncate (diffUTCTime now t) < 60 * feedRefreshTime cfg
mbCached <- lookupCache file
case mbCached of
Just (modtime, contents) | isRecentEnough modtime -> do
Expand Down
2 changes: 1 addition & 1 deletion gitit.cabal
Expand Up @@ -138,7 +138,7 @@ Executable gitit
pandoc-types >= 1.9.0.2 && < 1.10,
process,
filepath,
directory,
directory >= 1.2,
mtl,
cgi,
old-time,
Expand Down