summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Backend/Hash.hs15
-rw-r--r--Command/Migrate.hs2
-rw-r--r--Types/Backend.hs2
-rw-r--r--debian/changelog2
4 files changed, 15 insertions, 6 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
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index 19fd89c7a..a7198c71f 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -72,7 +72,7 @@ perform file oldkey oldbackend newbackend = go =<< genkey
checkcontent = Command.Fsck.checkBackend oldbackend oldkey $ Just file
finish newkey = stopUnless (Command.ReKey.linkKey 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)
Nothing -> do
content <- calcRepo $ gitAnnexLocation oldkey
diff --git a/Types/Backend.hs b/Types/Backend.hs
index 5c5855bc3..117ce8b24 100644
--- a/Types/Backend.hs
+++ b/Types/Backend.hs
@@ -21,7 +21,7 @@ data BackendA a = Backend
, canUpgradeKey :: Maybe (Key -> Bool)
-- Checks if there is a fast way to migrate a key to a different
-- 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
-- same data.
, isStableKey :: Key -> Bool
diff --git a/debian/changelog b/debian/changelog
index 876753566..f4a5933ed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ git-annex (5.20141232) UNRELEASED; urgency=medium
* unlock: Don't allow unlocking files that have never been committed to git
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.
+ « 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