Skip to content

Commit

Permalink
Code update
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Jan 25, 2017
1 parent d90a38b commit b7f6bc6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions mega-sdist.hs
Expand Up @@ -23,6 +23,7 @@ import Control.Monad.IO.Class (liftIO)
import Shelly hiding ((</>))
import Data.Maybe (mapMaybe, fromMaybe)
import Network (withSocketsDo)
import Control.Monad.Trans.Resource (runResourceT)

debug :: String -> IO ()
#ifdef DEBUG
Expand All @@ -39,8 +40,17 @@ getUrlHackage :: Package
#endif
getUrlHackage (Package a b) = do
debug url
#if MIN_VERSION_http_conduit(2, 2, 0)
req <- parseRequest url
#else
req <- parseUrl url
return req { responseTimeout = Nothing }
#endif
return req
#if MIN_VERSION_http_conduit(2, 2, 0)
{ responseTimeout = responseTimeoutNone }
#else
{ responseTimeout = Nothing }
#endif
where
url = concat
[ "http://hackage.haskell.org/packages/archive/"
Expand Down Expand Up @@ -139,13 +149,16 @@ go m fp = do
| fh -> handleFile localFileHackage NoChanges
| otherwise -> do
reqH <- getUrlHackage package
resH <- C.runResourceT $ httpLbs reqH
resH <- runResourceT $ httpLbs reqH
#if !MIN_VERSION_http_conduit(2, 2, 0)
#if MIN_VERSION_http_conduit(1, 9, 0)
{ checkStatus = \_ _ _ -> Nothing
#else
{ checkStatus = \_ _ -> Nothing
#endif
} m
}
#endif
m
case () of
()
| responseStatus resH == status404 || L.length (responseBody resH) == 0 -> do
Expand Down Expand Up @@ -183,7 +196,7 @@ compareTGZ a b = {- FIXME catcher $ -} do
-- catcher = handle (\SomeException{} -> debug (show ("compareTGZ" :: String, a, b)) >> return True)
getContents fp = do
lbs <- L.readFile (encodeString fp)
ebss <- try $ C.runResourceT $ CL.sourceList (L.toChunks lbs) C.$$ ungzip C.=$ CL.consume
ebss <- try $ runResourceT $ CL.sourceList (L.toChunks lbs) C.$$ ungzip C.=$ CL.consume
case ebss of
Left (e :: SomeException) -> do
putStrLn $ concat
Expand Down

0 comments on commit b7f6bc6

Please sign in to comment.