summaryrefslogtreecommitdiff
path: root/Command/Migrate.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-16 22:36:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-16 22:36:56 -0400
commit156a631f63eb0b2cee6a1b223d8e12ff8c62cb16 (patch)
tree8a48af241ea3c5601e5114cf11c3679e39c6fee3 /Command/Migrate.hs
parent69a0161c3afb9d6f7062ffac206044d95d3ee85a (diff)
make Migrate use ReKey rather than the other way around
as ReKey is plumbing, this makes sense
Diffstat (limited to 'Command/Migrate.hs')
-rw-r--r--Command/Migrate.hs28
1 files changed, 4 insertions, 24 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index 795ecc265..b837ef827 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -12,8 +12,7 @@ import Command
import qualified Backend
import qualified Types.Key
import Annex.Content
-import qualified Command.Add
-import Logs.Web
+import qualified Command.ReKey
def :: [Command]
def = [command "migrate" paramPaths seek "switch data to different backend"]
@@ -58,27 +57,8 @@ perform file oldkey newbackend = do
cleantmp tmpfile
case k of
Nothing -> stop
- Just (newkey, _) -> stopUnless (linkKey src newkey) $
- next $ cleanup file oldkey newkey
+ Just (newkey, _) ->
+ stopUnless (Command.ReKey.linkKey oldkey newkey) $
+ next $ Command.ReKey.cleanup file oldkey newkey
where
cleantmp t = liftIO $ whenM (doesFileExist t) $ removeFile t
-
-linkKey :: FilePath -> Key -> Annex Bool
-linkKey src newkey = getViaTmpUnchecked newkey $ \t -> do
- -- Make a hard link to the old backend's
- -- cached key, to avoid wasting disk space.
- liftIO $ unlessM (doesFileExist t) $ createLink src t
- return True
-
-cleanup :: FilePath -> Key -> Key -> CommandCleanup
-cleanup file oldkey newkey = do
- -- Update symlink to use the new key.
- liftIO $ removeFile file
-
- -- If the old key had some associated urls, record them for
- -- the new key as well.
- urls <- getUrls oldkey
- unless (null urls) $
- mapM_ (setUrlPresent newkey) urls
-
- Command.Add.cleanup file newkey True