avoid interrupted push leaving remote without a manifest
Added a backup manifest key, which is used if the main manifest key is not present. When uploading a new Manifest, it makes sure that it never drops one key except when the other key is present. It's entirely possible for the two manifest keys to get out of sync, due to races. The main one wins when it's present, it is possible for the main one being dropped to expose the backup one, which has a different push recorded.
This commit is contained in:
parent
594ca2fd3a
commit
3a38520aac
4 changed files with 67 additions and 67 deletions
|
@ -84,9 +84,10 @@ genGitBundleKey remoteuuid file meterupdate = do
|
|||
, keySize = Just filesize
|
||||
}
|
||||
|
||||
genManifestKey :: UUID -> Key
|
||||
genManifestKey u = mkKey $ \kd -> kd
|
||||
{ keyName = S.toShort (fromUUID u)
|
||||
genManifestKey :: UUID -> Maybe S.ShortByteString -> Key
|
||||
genManifestKey u extension = mkKey $ \kd -> kd
|
||||
{ keyName = S.toShort (fromUUID u) <>
|
||||
maybe mempty ("." <>) extension
|
||||
, keyVariety = GitManifestKey
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,14 @@ isGitRemoteAnnexKey u k =
|
|||
-- Remove the checksum that comes after the UUID.
|
||||
let b' = B8.dropWhileEnd (/= '-') b
|
||||
in B8.take (B8.length b' - 1) b'
|
||||
GitManifestKey -> sameuuid id
|
||||
GitManifestKey -> sameuuid $ \b ->
|
||||
-- Remove an optional extension after the UUID.
|
||||
-- (A UUID never contains '.')
|
||||
if '.' `B8.elem` b
|
||||
then
|
||||
let b' = B8.dropWhileEnd (/= '.') b
|
||||
in B8.take (B8.length b' - 1) b'
|
||||
else b
|
||||
_ -> False
|
||||
where
|
||||
sameuuid f = fromUUID u == f (S.fromShort (fromKey keyName k))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue