summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-14 15:37:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-14 15:37:24 -0400
commitea7f916c04e0b1ee022b3e4987be749db28fa2fa (patch)
tree0698a987c4b475fdccfe48bb2a8f1abebf55b844 /Command
parentc2f6f82a146339bb4b94acff1aae4f12ad023a08 (diff)
parent724d5185d48aee309af1a6d13927c4f7108610fd (diff)
Merge branch 'master' into windows
Conflicts: Annex/Environment.hs Build/Configure.hs Git/Construct.hs Utility/FileMode.hs
Diffstat (limited to 'Command')
-rw-r--r--Command/Migrate.hs19
1 files changed, 12 insertions, 7 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index d8bfd74f1..0fdf0e817 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -52,15 +52,20 @@ upgradableKey backend key = isNothing (Types.Key.keySize key) || backendupgradab
{- 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. -}
+ - be other files still pointing at that key.
+ -
+ - To ensure that the data we have for the old key is valid, it's
+ - fscked here. First we generate the new key. This ensures that the
+ - data cannot get corrupted after the fsck but before the new key is
+ - generated.
+ -}
perform :: FilePath -> Key -> Backend -> Backend -> CommandPerform
-perform file oldkey oldbackend newbackend = do
- ifM (Command.Fsck.checkBackend oldbackend oldkey (Just file))
- ( maybe stop go =<< genkey
- , stop
- )
+perform file oldkey oldbackend newbackend = go =<< genkey
where
- go newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $
+ go Nothing = stop
+ go (Just newkey) = stopUnless checkcontent $ finish newkey
+ checkcontent = Command.Fsck.checkBackend oldbackend oldkey $ Just file
+ finish newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $
next $ Command.ReKey.cleanup file oldkey newkey
genkey = do
content <- calcRepo $ gitAnnexLocation oldkey