Avoid re-checksumming when migrating from hash to hashE backend. Closes: #774494

This commit is contained in:
Joey Hess 2015-01-04 12:33:10 -04:00
parent e26e26fb32
commit 73928c2274
4 changed files with 15 additions and 6 deletions

View file

@ -1,4 +1,4 @@
{- git-annex hashing backends {- git-tnnex hashing backends
- -
- Copyright 2011-2013 Joey Hess <joey@kitenet.net> - Copyright 2011-2013 Joey Hess <joey@kitenet.net>
- -
@ -132,13 +132,20 @@ needsUpgrade :: Key -> Bool
needsUpgrade key = "\\" `isPrefixOf` keyHash key || needsUpgrade key = "\\" `isPrefixOf` keyHash key ||
any (not . validExtension) (takeExtensions $ keyName key) any (not . validExtension) (takeExtensions $ keyName key)
{- Fast migration from hashE to hash backend. (Optimisation) -} trivialMigrate :: Key -> Backend -> AssociatedFile -> Maybe Key
trivialMigrate :: Key -> Backend -> Maybe Key trivialMigrate oldkey newbackend afile
trivialMigrate oldkey newbackend {- Fast migration from hashE to hash backend. -}
| keyBackendName oldkey == name newbackend ++ "E" = Just $ oldkey | keyBackendName oldkey == name newbackend ++ "E" = Just $ oldkey
{ keyName = keyHash oldkey { keyName = keyHash oldkey
, keyBackendName = name newbackend , keyBackendName = name newbackend
} }
{- Fast migration from hash to hashE backend. -}
| keyBackendName oldkey ++"E" == name newbackend = case afile of
Nothing -> Nothing
Just file -> Just $ oldkey
{ keyName = keyHash oldkey ++ selectExtension file
, keyBackendName = name newbackend
}
| otherwise = Nothing | otherwise = Nothing
hashFile :: Hash -> FilePath -> Integer -> Annex String hashFile :: Hash -> FilePath -> Integer -> Annex String

View file

@ -72,7 +72,7 @@ perform file oldkey oldbackend newbackend = go =<< genkey
checkcontent = Command.Fsck.checkBackend oldbackend oldkey $ Just file checkcontent = Command.Fsck.checkBackend oldbackend oldkey $ Just file
finish newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $ finish newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $
next $ Command.ReKey.cleanup file oldkey newkey next $ Command.ReKey.cleanup file oldkey newkey
genkey = case maybe Nothing (\fm -> fm oldkey newbackend) (fastMigrate oldbackend) of genkey = case maybe Nothing (\fm -> fm oldkey newbackend (Just file)) (fastMigrate oldbackend) of
Just newkey -> return $ Just (newkey, True) Just newkey -> return $ Just (newkey, True)
Nothing -> do Nothing -> do
content <- calcRepo $ gitAnnexLocation oldkey content <- calcRepo $ gitAnnexLocation oldkey

View file

@ -21,7 +21,7 @@ data BackendA a = Backend
, canUpgradeKey :: Maybe (Key -> Bool) , canUpgradeKey :: Maybe (Key -> Bool)
-- Checks if there is a fast way to migrate a key to a different -- Checks if there is a fast way to migrate a key to a different
-- backend (ie, without re-hashing). -- backend (ie, without re-hashing).
, fastMigrate :: Maybe (Key -> BackendA a -> Maybe Key) , fastMigrate :: Maybe (Key -> BackendA a -> AssociatedFile -> Maybe Key)
-- Checks if a key is known (or assumed) to always refer to the -- Checks if a key is known (or assumed) to always refer to the
-- same data. -- same data.
, isStableKey :: Key -> Bool , isStableKey :: Key -> Bool

2
debian/changelog vendored
View file

@ -3,6 +3,8 @@ git-annex (5.20141232) UNRELEASED; urgency=medium
* unlock: Don't allow unlocking files that have never been committed to git * unlock: Don't allow unlocking files that have never been committed to git
before, to avoid an intractable problem that prevents the pre-commit before, to avoid an intractable problem that prevents the pre-commit
hook from telling if such a file is intended to be an annexed file or not. hook from telling if such a file is intended to be an annexed file or not.
« Avoid re-checksumming when migrating from hash to hashE backend.
Closes: #774494
-- Joey Hess <id@joeyh.name> Fri, 02 Jan 2015 13:35:13 -0400 -- Joey Hess <id@joeyh.name> Fri, 02 Jan 2015 13:35:13 -0400