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.
This commit is contained in:
Joey Hess 2024-08-08 14:03:02 -04:00
parent a2eb3b450a
commit c84d1a9462
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View 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