diff options
author | Joey Hess <joey@kitenet.net> | 2013-05-13 14:27:39 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-05-13 14:27:39 -0400 |
commit | bcea6a777569d7a4188a4f4d94a84f7477cbc366 (patch) | |
tree | ab3ab8c560903294ab9acb871bf091564e7aa662 /Command/Migrate.hs | |
parent | 01fd60a145872cd40f66bf8d3c8eaeeea25d3837 (diff) |
migrate: Detect if a file gets corrupted while it's being migrated.
Diffstat (limited to 'Command/Migrate.hs')
-rw-r--r-- | Command/Migrate.hs | 19 |
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 |