summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2017-01-23 15:53:24 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2017-01-23 15:53:24 +0100
commit95578246e6d6ea35be5936f3106e59bc8e594512 (patch)
treed1ea033d103b0c14076ca86c3a03515d9bd172df
parent0790ebde67e960d53d6f7eefe4083816e7ac8204 (diff)
downloadhakyll-95578246e6d6ea35be5936f3106e59bc8e594512.tar.gz
Fix ifdefs in Hakyll.Check
Fixes #518
-rw-r--r--src/Hakyll/Check.hs28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/Hakyll/Check.hs b/src/Hakyll/Check.hs
index c726485..da77bac 100644
--- a/src/Hakyll/Check.hs
+++ b/src/Hakyll/Check.hs
@@ -8,8 +8,13 @@ module Hakyll.Check
--------------------------------------------------------------------------------
-import Control.Monad (forM_, foldM)
-import Control.Monad.Reader (ask, ReaderT, runReaderT)
+import Control.Concurrent.MVar (MVar, newEmptyMVar, putMVar,
+ readMVar)
+import Control.Exception (SomeAsyncException (..),
+ SomeException (..), throw, try)
+import Control.Monad (foldM, forM_)
+import Control.Monad.Reader (ReaderT, ask, runReaderT)
+import Control.Monad.State (StateT, get, modify, runStateT)
import Control.Monad.Trans (liftIO)
import Control.Monad.Trans.Resource (runResourceT)
import Data.ByteString.Char8 (unpack)
@@ -21,16 +26,11 @@ import System.Directory (doesDirectoryExist,
import System.Exit (ExitCode (..))
import System.FilePath (takeDirectory, takeExtension,
(</>))
-import Control.Concurrent.MVar (MVar, newEmptyMVar, putMVar,
- readMVar)
import qualified Text.HTML.TagSoup as TS
--------------------------------------------------------------------------------
#ifdef CHECK_EXTERNAL
-import Control.Exception (SomeAsyncException (..),
- SomeException (..), try, throw)
-import Control.Monad.State (get, modify, StateT, runStateT)
import Data.List (intercalate)
import Data.Typeable (cast)
import Data.Version (versionBranch)
@@ -186,7 +186,7 @@ skip :: URL -> Maybe String -> Checker ()
skip url maybeReason = do
logger <- checkerLogger <$> ask
case maybeReason of
- Nothing -> return ()
+ Nothing -> return ()
Just reason -> Logger.debug logger reason
putCheckResult url mempty {checkerOk = 1}
@@ -241,19 +241,14 @@ checkExternalUrl url = do
Left (SomeException e) ->
case (cast e :: Maybe SomeAsyncException) of
Just ae -> throw ae
- _ -> faulty url (Just $ showException e)
+ _ -> faulty url (Just $ showException e)
Right _ -> ok url
where
-- Convert exception to a concise form
showException e = case cast e of
Just (Http.HttpExceptionRequest _ e') -> show e'
- _ -> head $ words $ show e
-#else
-checkExternalUrl url = skip url Nothing
-#endif
+ _ -> head $ words $ show e
-
---------------------------------------------------------------------------------
requestExternalUrl :: URL -> Checker (Either SomeException Bool)
requestExternalUrl url = liftIO $ try $ do
mgr <- Http.newManager Http.tlsManagerSettings
@@ -273,6 +268,9 @@ requestExternalUrl url = liftIO $ try $ do
-- Nice user agent info
ua = fromString $ "hakyll-check/" ++
(intercalate "." $ map show $ versionBranch Paths_hakyll.version)
+#else
+checkExternalUrl url = skip url Nothing
+#endif
--------------------------------------------------------------------------------