avoid redundant set of a S3 verison ID that is already recorded
authorJoey Hess <joeyh@joeyh.name>
Thu, 17 Dec 2020 20:49:17 +0000 (16:49 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 17 Dec 2020 20:49:17 +0000 (16:49 -0400)
I think this could cause unnecessary changes to the git-annex branch,
and retrieveExportWithContentIdentifier is now also used for getting
content from importtree=yes remotes, so it would happen more frequently
so let's avoid.

Remote/S3.hs

index ea8bab5d502fef33122f4e2211c3b1592092ea63..b35a62186ee02f11303282fe525da863d15a5db9 100644 (file)
@@ -656,7 +656,10 @@ retrieveExportWithContentIdentifierS3 hv r rs info loc cid dest mkkey p = withS3
                                S3.getObject (bucket info) o
                k <- mkkey
                case extractContentIdentifier cid o of
-                       Right vid -> setS3VersionID info rs k vid
+                       Right vid -> do
+                               vids <- getS3VersionID rs k
+                               unless (vid `elem` map Just vids) $
+                                       setS3VersionID info rs k vid
                        Left _ -> noop
                return k
        Nothing -> giveup $ needS3Creds (uuid r)
@@ -1132,7 +1135,7 @@ getPublicUrlMaker info = case publicurl info of
 -- version id involves a request for an object, so this keeps track of what
 -- the object is.
 data S3VersionID = S3VersionID S3.Object T.Text
-       deriving (Show)
+       deriving (Show, Eq)
 
 -- smart constructor
 mkS3VersionID :: S3.Object -> Maybe T.Text -> Maybe S3VersionID