From c84d1a9462fa6a1f1734591cf0fb4407b64a2398 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 8 Aug 2024 14:03:02 -0400 Subject: [PATCH] update export db after rename from annexobjects location 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 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Command/Export.hs b/Command/Export.hs index aa80d3af44..f09cec2b43 100644 --- a/Command/Export.hs +++ b/Command/Export.hs @@ -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