S3: Avoid writing or checking the uuid file in the S3 bucket when importtree=yes or exporttree=yes
It does not make sense for either; importing from an existing bucket should not write to it. And the user may not have write access at all. And exporting to a bucket should not write other files. Also this prevents the uuid file being imported after being written. Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
parent
c3df38dd15
commit
093ad89ead
2 changed files with 17 additions and 9 deletions
|
@ -15,6 +15,8 @@ git-annex (10.20220625) UNRELEASED; urgency=medium
|
|||
This may need to be enabled for old android devices that used to work
|
||||
without it being set, since version 10.20220222 started using
|
||||
find -printf.
|
||||
* S3: Avoid writing or checking the uuid file in the S3 bucket when
|
||||
importtree=yes or exporttree=yes.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Tue, 28 Jun 2022 14:49:17 -0400
|
||||
|
||||
|
|
24
Remote/S3.hs
24
Remote/S3.hs
|
@ -777,9 +777,11 @@ genBucket c gc u = do
|
|||
-
|
||||
- Note that IA buckets can only created by having a file
|
||||
- stored in them. So this also takes care of that.
|
||||
-
|
||||
- Not done for import/export buckets.
|
||||
-}
|
||||
writeUUIDFile :: ParsedRemoteConfig -> UUID -> S3Info -> S3Handle -> Annex ()
|
||||
writeUUIDFile c u info h = do
|
||||
writeUUIDFile c u info h = unless (exportTree c || importTree c) $ do
|
||||
v <- checkUUIDFile c u info h
|
||||
case v of
|
||||
Right True -> noop
|
||||
|
@ -794,15 +796,19 @@ writeUUIDFile c u info h = do
|
|||
mkobject = putObject info file (RequestBodyLBS uuidb)
|
||||
|
||||
{- Checks if the UUID file exists in the bucket
|
||||
- and has the specified UUID already. -}
|
||||
- and has the specified UUID already.
|
||||
-
|
||||
- Not done for import/export buckets. -}
|
||||
checkUUIDFile :: ParsedRemoteConfig -> UUID -> S3Info -> S3Handle -> Annex (Either SomeException Bool)
|
||||
checkUUIDFile c u info h = tryNonAsync $ liftIO $ runResourceT $ do
|
||||
resp <- tryS3 $ sendS3Handle h (S3.getObject (bucket info) file)
|
||||
case resp of
|
||||
Left _ -> return False
|
||||
Right r -> do
|
||||
v <- AWS.loadToMemory r
|
||||
extractFromResourceT (check v)
|
||||
checkUUIDFile c u info h
|
||||
| exportTree c || importTree c = pure (Right False)
|
||||
| otherwise = tryNonAsync $ liftIO $ runResourceT $ do
|
||||
resp <- tryS3 $ sendS3Handle h (S3.getObject (bucket info) file)
|
||||
case resp of
|
||||
Left _ -> return False
|
||||
Right r -> do
|
||||
v <- AWS.loadToMemory r
|
||||
extractFromResourceT (check v)
|
||||
where
|
||||
check (S3.GetObjectMemoryResponse _meta rsp) =
|
||||
responseStatus rsp == ok200 && responseBody rsp == uuidb
|
||||
|
|
Loading…
Reference in a new issue