]> dgit.raspbian.org Git - git-annex.git/commitdiff
update export db after rename from annexobjects location
authorJoey Hess <joeyh@joeyh.name>
Thu, 8 Aug 2024 18:03:02 +0000 (14:03 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 8 Aug 2024 18:03:02 +0000 (14:03 -0400)
This allows git-annex post-receive, on the first push to
the remote to see that it is able to get a key from it in
order to upload it back.

Also avoided actively checking if the source remote contains a key.
The location log is good enough. If the location log is wrong,
the export of that file will fail with an informative message.

Command/Export.hs

index aa80d3af44bd6dfdcad33cf684af845de76e604c..f09cec2b433e19f917822a4fd711d855aae8f831 100644 (file)
@@ -43,6 +43,7 @@ import Utility.Matcher
 import qualified Data.ByteString.Char8 as S8
 import qualified Data.ByteString.Lazy as L
 import qualified Data.Map as M
+import qualified Data.Set as S
 import Control.Concurrent
 
 cmd :: Command
@@ -325,11 +326,13 @@ performExport r srcrs db ek af contentsha loc allfilledvar = do
        
        sendannexobject = ifM (inAnnex ek)
                ( sendlocalannexobject
-               , firstM remotehaskey srcrs >>= \case
-                       Nothing -> do   
-                               showNote "not available"
-                               return False
-                       Just srcr -> getsendannexobject srcr
+               , do
+                       locs <- S.fromList <$> loggedLocations ek
+                       case filter (\sr -> S.member (Remote.uuid sr) locs) srcrs of
+                               [] -> do
+                                       showNote "not available"
+                                       return False
+                               (srcr:_) -> getsendannexobject srcr
                )
        
        sendlocalannexobject = sendwith $ \p -> do
@@ -347,8 +350,6 @@ performExport r srcrs db ek af contentsha loc allfilledvar = do
                        -- of the content should still be allowed.
                        alwaysUpload (uuid r) ek af Nothing stdRetry a
 
-       remotehaskey srcr = either (const False) id <$> Remote.hasKey srcr ek
-
        -- Similar to Command.Move.fromToPerform, use a regular download
        -- of a local copy, lock early, and drop the local copy after sending.
        getsendannexobject srcr = do
@@ -370,7 +371,10 @@ performExport r srcrs db ek af contentsha loc allfilledvar = do
                                        let objloc = exportAnnexObjectLocation gc ek
                                        if Remote.uuid r `elem` locs
                                                then tryNonAsync (renameaction ek objloc loc) >>= \case
-                                                       Right (Just ()) -> return True
+                                                       Right (Just ()) -> do
+                                                               liftIO $ addExportedLocation db ek loc
+                                                               liftIO $ flushDbQueue db
+                                                               return True
                                                        Left _err -> fallback
                                                        Right Nothing -> fallback
                                                else fallback