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,
|
backends,
|
||||||
genGitBundleKey,
|
genGitBundleKey,
|
||||||
genManifestKey,
|
genManifestKey,
|
||||||
|
genBackupManifestKey,
|
||||||
isGitRemoteAnnexKey,
|
isGitRemoteAnnexKey,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
@ -84,10 +85,16 @@ genGitBundleKey remoteuuid file meterupdate = do
|
||||||
, keySize = Just filesize
|
, keySize = Just filesize
|
||||||
}
|
}
|
||||||
|
|
||||||
genManifestKey :: UUID -> Maybe S.ShortByteString -> Key
|
genManifestKey :: UUID -> Key
|
||||||
genManifestKey u extension = mkKey $ \kd -> kd
|
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) <>
|
{ keyName = S.toShort (fromUUID u) <>
|
||||||
maybe mempty ("." <>) extension
|
fromMaybe mempty extension
|
||||||
, keyVariety = GitManifestKey
|
, keyVariety = GitManifestKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -587,8 +587,8 @@ downloadManifestOrFail rmt =
|
||||||
downloadManifest :: Remote -> Annex (Maybe Manifest)
|
downloadManifest :: Remote -> Annex (Maybe Manifest)
|
||||||
downloadManifest rmt = get mkmain >>= maybe (get mkbak) (pure . Just)
|
downloadManifest rmt = get mkmain >>= maybe (get mkbak) (pure . Just)
|
||||||
where
|
where
|
||||||
mkmain = genManifestKey (Remote.uuid rmt) Nothing
|
mkmain = genManifestKey (Remote.uuid rmt)
|
||||||
mkbak = genManifestKey (Remote.uuid rmt) (Just "bak")
|
mkbak = genBackupManifestKey (Remote.uuid rmt)
|
||||||
|
|
||||||
get mk = getKeyExportLocations rmt mk >>= \case
|
get mk = getKeyExportLocations rmt mk >>= \case
|
||||||
Nothing -> ifM (Remote.checkPresent rmt mk)
|
Nothing -> ifM (Remote.checkPresent rmt mk)
|
||||||
|
@ -654,8 +654,8 @@ uploadManifest rmt manifest = do
|
||||||
then void $ dropOldKeys rmt manifest (const True)
|
then void $ dropOldKeys rmt manifest (const True)
|
||||||
else uploadfailed
|
else uploadfailed
|
||||||
where
|
where
|
||||||
mkmain = genManifestKey (Remote.uuid rmt) Nothing
|
mkmain = genManifestKey (Remote.uuid rmt)
|
||||||
mkbak = genManifestKey (Remote.uuid rmt) (Just "bak")
|
mkbak = genBackupManifestKey (Remote.uuid rmt)
|
||||||
|
|
||||||
uploadfailed = giveup "Failed to upload manifest."
|
uploadfailed = giveup "Failed to upload manifest."
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue