Skip to content

Commit

Permalink
Map chunked MD5s to md5zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Herbert Valerio Riedel committed Sep 22, 2016
1 parent 2d14580 commit aab83fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

module Common
( module Common
, module Control.Applicative
, module Data.Maybe
, module Hackage.Security.Util.Path
, module Data.Semigroup
Expand All @@ -16,6 +17,7 @@ module Common
, NFData
) where

import Control.Applicative
import Control.DeepSeq
import Control.Exception
import qualified Crypto.Hash.MD5 as MD5
Expand Down
7 changes: 6 additions & 1 deletion src/SimpleS3.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 "-<num>" 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_
Expand Down

0 comments on commit aab83fa

Please sign in to comment.