summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-14 00:18:18 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-14 00:18:18 -0400
commit7f45baee5e7c9e98e6ccf24a6b366dee9d577bc1 (patch)
tree5fc298b0070364ebedcff59294db8c832670c2ee
parentac67b4ed00928b9399fa4c7147a9c0fcbe0ace5f (diff)
migrate: Check content before generating the new key, to avoid generating a key for corrupt data.
-rw-r--r--Command/Migrate.hs11
-rw-r--r--debian/changelog2
2 files changed, 10 insertions, 3 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index c7c0d7af3..d3b29eeca 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -14,6 +14,7 @@ import qualified Types.Key
import Types.KeySource
import Annex.Content
import qualified Command.ReKey
+import qualified Command.Fsck
def :: [Command]
def = [command "migrate" paramPaths seek "switch data to different backend"]
@@ -28,7 +29,7 @@ start file (key, oldbackend) = do
if (newbackend /= oldbackend || upgradableKey key) && exists
then do
showStart "migrate" file
- next $ perform file key newbackend
+ next $ perform file key oldbackend newbackend
else stop
where
choosebackend Nothing = Prelude.head <$> orderedList
@@ -42,8 +43,12 @@ upgradableKey key = isNothing $ Types.Key.keySize key
{- Store the old backend's key in the new backend
- The old backend's key is not dropped from it, because there may
- be other files still pointing at that key. -}
-perform :: FilePath -> Key -> Backend -> CommandPerform
-perform file oldkey newbackend = maybe stop go =<< genkey
+perform :: FilePath -> Key -> Backend -> Backend -> CommandPerform
+perform file oldkey oldbackend newbackend = do
+ ifM (Command.Fsck.checkBackend oldbackend oldkey)
+ ( maybe stop go =<< genkey
+ , stop
+ )
where
go newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $
next $ Command.ReKey.cleanup file oldkey newkey
diff --git a/debian/changelog b/debian/changelog
index 0c0b34e0e..fe1dd4c87 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -15,6 +15,8 @@ git-annex (3.20120826) UNRELEASED; urgency=low
Closes: #682351 Thanks, gregor herrmann
* Disable ssh connection caching if the path to the control socket would be
too long (and use relative path to minimise path to the control socket).
+ * migrate: Check content before generating the new key, to avoid generating
+ a key for corrupt data.
-- Joey Hess <joeyh@debian.org> Mon, 27 Aug 2012 13:27:39 -0400