diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-01-04 12:33:10 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-01-04 12:33:10 -0400 |
commit | 2963de7dade0a314a5fc626114fe8de364c4ff13 (patch) | |
tree | 4c1d85a771751cd3784a8d38c0d3da2b46a2715c /Backend | |
parent | b3eaa4108f0f4e0df8c1642c4c65b6f9ef7f4bce (diff) |
Avoid re-checksumming when migrating from hash to hashE backend. Closes: #774494
Diffstat (limited to 'Backend')
-rw-r--r-- | Backend/Hash.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs index 7c47a4abc..e50eca516 100644 --- a/Backend/Hash.hs +++ b/Backend/Hash.hs @@ -1,4 +1,4 @@ -{- git-annex hashing backends +{- git-tnnex hashing backends - - Copyright 2011-2013 Joey Hess <joey@kitenet.net> - @@ -132,13 +132,20 @@ 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 +trivialMigrate :: Key -> Backend -> AssociatedFile -> Maybe Key +trivialMigrate oldkey newbackend afile + {- Fast migration from hashE to hash backend. -} | keyBackendName oldkey == name newbackend ++ "E" = Just $ oldkey { keyName = keyHash oldkey , 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 hashFile :: Hash -> FilePath -> Integer -> Annex String |