aboutsummaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-10 17:06:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-10 17:06:04 -0400
commitb873f05ca7e86344a28d269d682b7ffd8a88baca (patch)
tree2e1191a0e0ded12d30d913937e7335230e5fde9d /Backend
parent490f52bbab0d6757dbe4b41bab2e39508899efea (diff)
migrate: Avoid re-checksumming when migrating from hashE to hash backend.
Diffstat (limited to 'Backend')
-rw-r--r--Backend/Hash.hs10
-rw-r--r--Backend/URL.hs1
-rw-r--r--Backend/WORM.hs1
3 files changed, 12 insertions, 0 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs
index 41368a5bb..3ff496271 100644
--- a/Backend/Hash.hs
+++ b/Backend/Hash.hs
@@ -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
diff --git a/Backend/URL.hs b/Backend/URL.hs
index a8161c98d..4233c56bc 100644
--- a/Backend/URL.hs
+++ b/Backend/URL.hs
@@ -24,6 +24,7 @@ backend = Backend
, getKey = const $ return Nothing
, fsckKey = Nothing
, canUpgradeKey = Nothing
+ , fastMigrate = Nothing
}
{- Every unique url has a corresponding key. -}
diff --git a/Backend/WORM.hs b/Backend/WORM.hs
index 60db42f56..cc7123850 100644
--- a/Backend/WORM.hs
+++ b/Backend/WORM.hs
@@ -22,6 +22,7 @@ backend = Backend
, getKey = keyValue
, fsckKey = Nothing
, canUpgradeKey = Nothing
+ , fastMigrate = Nothing
}
{- The key includes the file size, modification time, and the