summaryrefslogtreecommitdiff
path: root/Command/Migrate.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-17 00:19:47 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-17 00:19:47 -0400
commitf3c75b601f7a8a46d1e5a064f5c3eb5d828998ab (patch)
tree3a95463d8a518baeb822cb248f0583dc0971c306 /Command/Migrate.hs
parentba5515d4226a47bc89ad141bd8029a4f252ad28d (diff)
reorg
Diffstat (limited to 'Command/Migrate.hs')
-rw-r--r--Command/Migrate.hs26
1 files changed, 13 insertions, 13 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index b837ef827..6e28c4b52 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -47,18 +47,18 @@ upgradableKey key = isNothing $ Types.Key.keySize key
- generate.
-}
perform :: FilePath -> Key -> Backend -> CommandPerform
-perform file oldkey newbackend = do
- src <- inRepo $ gitAnnexLocation oldkey
- tmp <- fromRepo gitAnnexTmpDir
- let tmpfile = tmp </> takeFileName file
- cleantmp tmpfile
- liftIO $ createLink src tmpfile
- k <- Backend.genKey tmpfile $ Just newbackend
- cleantmp tmpfile
- case k of
- Nothing -> stop
- Just (newkey, _) ->
- stopUnless (Command.ReKey.linkKey oldkey newkey) $
- next $ Command.ReKey.cleanup file oldkey newkey
+perform file oldkey newbackend = maybe stop go =<< genkey
where
+ go newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $
+ next $ Command.ReKey.cleanup file oldkey newkey
+ genkey = do
+ src <- inRepo $ gitAnnexLocation oldkey
+ tmp <- fromRepo gitAnnexTmpDir
+ let tmpfile = tmp </> takeFileName file
+ cleantmp tmpfile
+ liftIO $ createLink src tmpfile
+ newkey <- liftM fst <$>
+ Backend.genKey tmpfile (Just newbackend)
+ cleantmp tmpfile
+ return newkey
cleantmp t = liftIO $ whenM (doesFileExist t) $ removeFile t