summaryrefslogtreecommitdiff
path: root/Command/Migrate.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-09 12:23:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-09 12:23:45 -0400
commit3f5f28b48754bc91620a6354ca70afe4c61c9894 (patch)
tree6c71b52187f442ce619ffac7c672fc7f0b8f84ce /Command/Migrate.hs
parentd64132a43ae176e8a1353d5463c5387a93da9ad7 (diff)
factor out a stopUnless
code melt for lunch
Diffstat (limited to 'Command/Migrate.hs')
-rw-r--r--Command/Migrate.hs24
1 files changed, 10 insertions, 14 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index c85d7c2ac..30288fc16 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -58,22 +58,18 @@ perform file oldkey newbackend = do
cleantmp tmpfile
case k of
Nothing -> stop
- Just (newkey, _) -> do
- ok <- link src newkey
- if ok
- then do
- -- Update symlink to use the new key.
- liftIO $ removeFile file
+ Just (newkey, _) -> stopUnless (link src 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
+ -- 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
- next $ Command.Add.cleanup file newkey True
- else stop
+ next $ Command.Add.cleanup file newkey True
where
cleantmp t = liftIO $ whenM (doesFileExist t) $ removeFile t
link src newkey = getViaTmpUnchecked newkey $ \t -> do