This commit is contained in:
Joey Hess 2024-05-21 09:51:19 -04:00
parent 5d40759470
commit 5f4ad2a5de
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 14 additions and 7 deletions

View file

@ -14,6 +14,7 @@ module Backend.GitRemoteAnnex (
backends,
genGitBundleKey,
genManifestKey,
genBackupManifestKey,
isGitRemoteAnnexKey,
) where
@ -84,10 +85,16 @@ genGitBundleKey remoteuuid file meterupdate = do
, keySize = Just filesize
}
genManifestKey :: UUID -> Maybe S.ShortByteString -> Key
genManifestKey u extension = mkKey $ \kd -> kd
genManifestKey :: UUID -> Key
genManifestKey = genManifestKey' Nothing
genBackupManifestKey :: UUID -> Key
genBackupManifestKey = genManifestKey' (Just ".bak")
genManifestKey' :: Maybe S.ShortByteString -> UUID -> Key
genManifestKey' extension u = mkKey $ \kd -> kd
{ keyName = S.toShort (fromUUID u) <>
maybe mempty ("." <>) extension
fromMaybe mempty extension
, keyVariety = GitManifestKey
}

View file

@ -587,8 +587,8 @@ downloadManifestOrFail rmt =
downloadManifest :: Remote -> Annex (Maybe Manifest)
downloadManifest rmt = get mkmain >>= maybe (get mkbak) (pure . Just)
where
mkmain = genManifestKey (Remote.uuid rmt) Nothing
mkbak = genManifestKey (Remote.uuid rmt) (Just "bak")
mkmain = genManifestKey (Remote.uuid rmt)
mkbak = genBackupManifestKey (Remote.uuid rmt)
get mk = getKeyExportLocations rmt mk >>= \case
Nothing -> ifM (Remote.checkPresent rmt mk)
@ -654,8 +654,8 @@ uploadManifest rmt manifest = do
then void $ dropOldKeys rmt manifest (const True)
else uploadfailed
where
mkmain = genManifestKey (Remote.uuid rmt) Nothing
mkbak = genManifestKey (Remote.uuid rmt) (Just "bak")
mkmain = genManifestKey (Remote.uuid rmt)
mkbak = genBackupManifestKey (Remote.uuid rmt)
uploadfailed = giveup "Failed to upload manifest."