refactor
This commit is contained in:
parent
5d40759470
commit
5f4ad2a5de
2 changed files with 14 additions and 7 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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."
|
||||
|
||||
|
|
Loading…
Reference in a new issue