summaryrefslogtreecommitdiff
path: root/Remote/S3.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-10-23 16:32:18 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-10-23 16:32:18 -0400
commit3fc2cf4ddcb54abdd30c31efef5e8588b4af358a (patch)
tree2db9044c333f0059c0408f6ad5e885643b54776d /Remote/S3.hs
parentdcf5503abb3125ee76c96b70fbe08353987ca156 (diff)
update for aws 0.10's better handling of DNE for HEAD
Kept support for older aws, since Debian has 0.9.2 still.
Diffstat (limited to 'Remote/S3.hs')
-rw-r--r--Remote/S3.hs35
1 files changed, 21 insertions, 14 deletions
diff --git a/Remote/S3.hs b/Remote/S3.hs
index 6969096d6..b818e2f9b 100644
--- a/Remote/S3.hs
+++ b/Remote/S3.hs
@@ -203,23 +203,30 @@ remove h k
checkKey :: Remote -> S3Handle -> CheckPresent
checkKey r h k = do
showAction $ "checking " ++ name r
+#if MIN_VERSION_aws(0,10,0)
+ rsp <- go
+ return (isJust $ S3.horMetadata r)
+#else
catchMissingException $ do
- void $ sendS3Handle h $
- S3.headObject (bucket (hinfo h)) (bucketObject (hinfo h) k)
+ void go
return True
-
-{- Catch exception headObject returns when an object is not present
- - in the bucket, and returns False. All other exceptions indicate a
- - check error and are let through. -}
-catchMissingException :: Annex Bool -> Annex Bool
-catchMissingException a = catchJust missing a (const $ return False)
+#endif
where
- -- This is not very good; see
- -- https://github.com/aristidb/aws/issues/121
- missing :: AWS.HeaderException -> Maybe ()
- missing e
- | AWS.headerErrorMessage e == "ETag missing" = Just ()
- | otherwise = Nothing
+ go = sendS3Handle h $
+ S3.headObject (bucket (hinfo h)) (bucketObject (hinfo h) k)
+
+#if ! MIN_VERSION_aws(0,10,0)
+ {- Catch exception headObject returns when an object is not present
+ - in the bucket, and returns False. All other exceptions indicate a
+ - check error and are let through. -}
+ catchMissingException :: Annex Bool -> Annex Bool
+ catchMissingException a = catchJust missing a (const $ return False)
+ where
+ missing :: AWS.HeaderException -> Maybe ()
+ missing e
+ | AWS.headerErrorMessage e == "ETag missing" = Just ()
+ | otherwise = Nothing
+#endif
{- Generate the bucket if it does not already exist, including creating the
- UUID file within the bucket.