From aab83fa7a6bfb983b715acc4b01cb212b0dd4cf5 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Thu, 22 Sep 2016 08:31:02 +0200 Subject: [PATCH] Map chunked MD5s to md5zero --- src/Common.hs | 2 ++ src/SimpleS3.hs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Common.hs b/src/Common.hs index 0c660d1..4cb9007 100644 --- a/src/Common.hs +++ b/src/Common.hs @@ -3,6 +3,7 @@ module Common ( module Common + , module Control.Applicative , module Data.Maybe , module Hackage.Security.Util.Path , module Data.Semigroup @@ -16,6 +17,7 @@ module Common , NFData ) where +import Control.Applicative import Control.DeepSeq import Control.Exception import qualified Crypto.Hash.MD5 as MD5 diff --git a/src/SimpleS3.hs b/src/SimpleS3.hs index 0451aa4..1412490 100644 --- a/src/SimpleS3.hs +++ b/src/SimpleS3.hs @@ -267,7 +267,12 @@ instance FromXML ObjMetaInfo where omiKey <- (fromString . X.strContent) <$> X.findChild (s3qname "Key") el omiEtag_ <- X.strContent <$> X.findChild (s3qname "ETag") el omiMD5' <- readMaybe omiEtag_ - omiMD5 <- md5unhex omiMD5' + -- sometimes the reported MD5 is computed over chunks, in + -- which case the etag has a "-" suffix. For now, we just + -- map those to the special zero MD5 as we can't do anything + -- sensible with it anyway (but we may want to be able to + -- detect that the MD5 reported was not a proper MD5) + omiMD5 <- md5unhex omiMD5' <|> Just md5zero omiSize_ <- X.strContent <$> X.findChild (s3qname "Size") el omiSize <- readMaybe omiSize_