migrate: Avoid re-checksumming when migrating from hashE to hash backend.

This commit is contained in:
Joey Hess 2014-07-10 17:06:04 -04:00
parent 564de5e508
commit 9d71903c2f
7 changed files with 34 additions and 12 deletions

View file

@ -44,6 +44,7 @@ genBackend hash = Just Backend
, getKey = keyValue hash
, fsckKey = Just $ checkKeyChecksum hash
, canUpgradeKey = Just needsUpgrade
, fastMigrate = Just trivialMigrate
}
genBackendE :: Hash -> Maybe Backend
@ -129,6 +130,15 @@ needsUpgrade :: Key -> Bool
needsUpgrade key = "\\" `isPrefixOf` keyHash key ||
any (not . validExtension) (takeExtensions $ keyName key)
{- Fast migration from hashE to hash backend. (Optimisation) -}
trivialMigrate :: Key -> Backend -> Maybe Key
trivialMigrate oldkey newbackend
| keyBackendName oldkey == name newbackend ++ "E" = Just $ oldkey
{ keyName = keyHash oldkey
, keyBackendName = name newbackend
}
| otherwise = Nothing
hashFile :: Hash -> FilePath -> Integer -> Annex String
hashFile hash file filesize = liftIO $ go hash
where

View file

@ -24,6 +24,7 @@ backend = Backend
, getKey = const $ return Nothing
, fsckKey = Nothing
, canUpgradeKey = Nothing
, fastMigrate = Nothing
}
{- Every unique url has a corresponding key. -}

View file

@ -22,6 +22,7 @@ backend = Backend
, getKey = keyValue
, fsckKey = Nothing
, canUpgradeKey = Nothing
, fastMigrate = Nothing
}
{- The key includes the file size, modification time, and the