[commit: packages/Cabal] ghc-head: Fix a corner case in etag code. (4102b0d)
git at git.haskell.org
git at git.haskell.org
Mon Aug 26 23:26:17 CEST 2013
Repository : ssh://git@git.haskell.org/Cabal
On branch : ghc-head
Link : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=4102b0d2a9fc681becb3826da2760fdc87af2600
>---------------------------------------------------------------
commit 4102b0d2a9fc681becb3826da2760fdc87af2600
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date: Wed May 29 15:47:58 2013 +0200
Fix a corner case in etag code.
>---------------------------------------------------------------
4102b0d2a9fc681becb3826da2760fdc87af2600
cabal-install/Distribution/Client/HttpUtils.hs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/cabal-install/Distribution/Client/HttpUtils.hs b/cabal-install/Distribution/Client/HttpUtils.hs
index b3ed932..8396079 100644
--- a/cabal-install/Distribution/Client/HttpUtils.hs
+++ b/cabal-install/Distribution/Client/HttpUtils.hs
@@ -103,8 +103,10 @@ downloadURI verbosity uri path | uriScheme uri == "file:" = do
-- hash matches to avoid unnecessary computation?
downloadURI verbosity uri path = do
let etagPath = path <.> "etag"
+ targetExists <- doesFileExist path
etagPathExists <- doesFileExist etagPath
- etag <- if etagPathExists
+ -- In rare cases the target file doesn't exist, but the etag does.
+ etag <- if targetExists && etagPathExists
then liftM Just $ readFile etagPath
else return Nothing
@@ -116,8 +118,8 @@ downloadURI verbosity uri path = do
(3,0,4) -> Right rsp
(a,b,c) -> Left err
where
- err = ErrorMisc $ "Unsucessful HTTP code: "
- ++ concatMap show [a,b,c]
+ err = ErrorMisc $ "Error HTTP code: "
+ ++ concatMap show [a,b,c]
-- Only write the etag if we get a 200 response code.
-- A 304 still sends us an etag header.
More information about the ghc-commits
mailing list