implement VURL to URL migration
Just for completeness, someone might want to downgrade I guess?
This commit is contained in:
parent
9e3ebc0c59
commit
b4811b74b1
2 changed files with 11 additions and 4 deletions
|
@ -17,6 +17,7 @@ import Logs.EquivilantKeys
|
|||
import Backend.Variety
|
||||
import Backend.Hash (descChecksum)
|
||||
import Utility.Hash
|
||||
import Backend.VURL.Utilities
|
||||
|
||||
backends :: [Backend]
|
||||
backends = [backendVURL]
|
||||
|
@ -69,7 +70,7 @@ backendVURL = Backend
|
|||
, descIncrementalVerifier = descChecksum
|
||||
}
|
||||
, canUpgradeKey = Nothing
|
||||
, fastMigrate = Nothing
|
||||
, fastMigrate = Just migrateFromVURLToURL
|
||||
-- Even if a hash is recorded on initial download from the web and
|
||||
-- is used to verify every subsequent transfer including other
|
||||
-- downloads from the web, in a split-brain situation there
|
||||
|
|
|
@ -27,14 +27,20 @@ migrateFromURLToVURL oldkey newbackend _af inannex
|
|||
Just ek -> do
|
||||
setEquivilantKey newkey ek
|
||||
return (Just newkey)
|
||||
| otherwise = do
|
||||
liftIO $ print ("migrateFromURL", inannex, fromKey keyVariety oldkey)
|
||||
return Nothing
|
||||
| otherwise = return Nothing
|
||||
where
|
||||
-- Relies on the first hash being cryptographically secure, and the
|
||||
-- default hash used by git-annex.
|
||||
hashbackend = Prelude.head Backend.Hash.backends
|
||||
|
||||
migrateFromVURLToURL :: Key -> Backend -> AssociatedFile -> Bool -> Annex (Maybe Key)
|
||||
migrateFromVURLToURL oldkey newbackend _af _
|
||||
| fromKey keyVariety oldkey == VURLKey && backendVariety newbackend == URLKey =
|
||||
return $ Just $ mkKey $ const $
|
||||
(keyData oldkey)
|
||||
{ keyVariety = URLKey }
|
||||
| otherwise = return Nothing
|
||||
|
||||
-- The Backend must use a cryptographically secure hash.
|
||||
generateEquivilantKey :: Backend -> RawFilePath -> Annex (Maybe Key)
|
||||
generateEquivilantKey b f =
|
||||
|
|
Loading…
Reference in a new issue