S3: Support versioning=yes with a readonly bucket.

Needs aws-0.24.3.
This commit is contained in:
Joey Hess 2024-11-12 14:32:23 -04:00
parent 03662e4d83
commit a16bf4f914
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 19 additions and 3 deletions

View file

@ -3,6 +3,8 @@ git-annex (10.20241032) UNRELEASED; urgency=medium
* git-remote-annex: Fix a reversion introduced in version 10.20241031
that broke cloning from a special remote.
* vpop: Only update state after successful checkout.
* S3: Support versioning=yes with a readonly bucket.
(Needs aws-0.24.3)
-- Joey Hess <id@joeyh.name> Mon, 11 Nov 2024 12:26:00 -0400

View file

@ -1341,11 +1341,24 @@ enableBucketVersioning ss info _ _ _ = do
where
enableversioning b = do
#if MIN_VERSION_aws(0,21,1)
showAction "enabling bucket versioning"
showAction "checking bucket versioning"
hdl <- mkS3HandleVar c gc u
let setversioning = S3.putBucketVersioning b S3.VersioningEnabled
withS3HandleOrFail u hdl $ \h ->
void $ liftIO $ runResourceT $ sendS3Handle h $
S3.putBucketVersioning b S3.VersioningEnabled
#if MIN_VERSION_aws(0,24,3)
liftIO $ runResourceT $
tryS3 (sendS3Handle h setversioning) >>= \case
Right _ -> return ()
Left err -> do
res <- sendS3Handle h $
S3.getBucketVersioning b
case S3.gbvVersioning res of
Just S3.VersioningEnabled -> return ()
_ -> giveup $ "This bucket does not have versioning enabled, and enabling it failed: "
++ T.unpack (S3.s3ErrorMessage err)
#else
void $ liftIO $ runResourceT $ sendS3Handle h go
#endif
#else
showLongNote $ unlines
[ "This version of git-annex cannot auto-enable S3 bucket versioning."

View file

@ -16,3 +16,4 @@ packages:
resolver: nightly-2024-07-29
extra-deps:
- filepath-bytestring-1.4.100.3.2
- aws-0.24.3