From 06142f49439450d41c29c72d7d7a39a85cbe891c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 25 Feb 2014 01:55:01 -0400 Subject: [PATCH] fix #740010 properly --- Remote/WebDAV.hs | 21 +++++++++------------ git-annex.cabal | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs index de1b721c9f..8ac9c2c79a 100644 --- a/Remote/WebDAV.hs +++ b/Remote/WebDAV.hs @@ -17,7 +17,11 @@ import qualified Data.ByteString.Lazy as L import Network.URI (normalizePathSegments) import qualified Control.Exception as E import qualified Control.Exception.Lifted as EL +#if MIN_VERSION_DAV(0,6,0) +import Network.HTTP.Client (HttpException(..)) +#else import Network.HTTP.Conduit (HttpException(..)) +#endif import Network.HTTP.Types import System.IO.Error @@ -355,8 +359,9 @@ mkdirDAV url user pass = #endif existsDAV :: DavUrl -> DavUser -> DavPass -> IO (Either String Bool) -existsDAV url user pass = either onerr id <$> tryNonAsync check +existsDAV url user pass = either (Left . show) id <$> tryNonAsync check where + ispresent = return . Right #if MIN_VERSION_DAV(0,6,0) check = goDAV url user pass $ do setDepth Nothing @@ -374,20 +379,12 @@ existsDAV url user pass = either onerr id <$> tryNonAsync check #endif (const $ ispresent False) #endif - ispresent = return . Right - {- This is a horrible hack, it seems that the type of the - - HttpException gets screwed up with DAV 0.6.x, and so - - I'm reduced to string matching. :( -} - onerr e - | "StatusCodeException" `isInfixOf` show e - && "statusCode = 404" `isInfixOf` show e = Right False - | otherwise = Left (show e) matchStatusCodeException :: Status -> HttpException -> Maybe () -#if ! MIN_VERSION_http_conduit(1,9,0) -matchStatusCodeException want (StatusCodeException s _) -#else +#if MIN_VERSION_DAV(0,6,0) matchStatusCodeException want (StatusCodeException s _ _) +#else +matchStatusCodeException want (StatusCodeException s _) #endif | s == want = Just () | otherwise = Nothing diff --git a/git-annex.cabal b/git-annex.cabal index 7ba1c7d783..d7bf6cad61 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -134,7 +134,7 @@ Executable git-annex if flag(WebDAV) Build-Depends: DAV ((>= 0.3 && < 0.6) || > 0.6), - http-conduit, xml-conduit, http-types, lifted-base + http-client, http-conduit, http-types, lifted-base CPP-Options: -DWITH_WEBDAV if flag(Assistant) && ! os(solaris)