fix deleting old keys in empty push

This commit is contained in:
Joey Hess 2024-05-21 11:53:03 -04:00
parent 7f768aef77
commit be535caffc
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -358,10 +358,10 @@ pushEmpty :: State -> Remote -> Annex (Bool, State)
pushEmpty st rmt = do pushEmpty st rmt = do
oldmanifest <- maybe (downloadManifestWhenPresent rmt) pure oldmanifest <- maybe (downloadManifestWhenPresent rmt) pure
(manifestCache st) (manifestCache st)
oldmanifest' <- dropOldKeys rmt oldmanifest (const True)
let manifest = mkManifest mempty let manifest = mkManifest mempty
(inManifest oldmanifest ++ outManifest oldmanifest') (inManifest oldmanifest ++ outManifest oldmanifest)
uploadManifest rmt manifest manifest' <- dropOldKeys rmt manifest
uploadManifest rmt manifest'
return (True, st { manifestCache = Nothing }) return (True, st { manifestCache = Nothing })
data RefSpec = RefSpec data RefSpec = RefSpec
@ -687,10 +687,10 @@ uploadManifest rmt manifest = do
-- --
-- If interrupted at this stage, or if a drop fails, the key remains -- If interrupted at this stage, or if a drop fails, the key remains
-- in the outManifest, so the drop will be tried again later. -- in the outManifest, so the drop will be tried again later.
dropOldKeys :: Remote -> Manifest -> (Key -> Bool) -> Annex Manifest dropOldKeys :: Remote -> Manifest -> Annex Manifest
dropOldKeys rmt manifest p = dropOldKeys rmt manifest =
mkManifest (inManifest manifest) mkManifest (inManifest manifest)
<$> filterM (dropKey rmt) (filter p (outManifest manifest)) <$> filterM (not <$$> dropKey rmt) (outManifest manifest)
-- When pushEmpty raced with another push, it could result in the manifest -- When pushEmpty raced with another push, it could result in the manifest
-- listing bundles that it deleted. Such a manifest has to be treated the -- listing bundles that it deleted. Such a manifest has to be treated the