summaryrefslogtreecommitdiff
path: root/Command/Migrate.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-17 03:10:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-17 03:13:11 -0400
commitc91929f6934fc4e94603d0fa004e824d5e2cfb65 (patch)
treee958f5b4dc1209afb90c786493164c351dea4b9a /Command/Migrate.hs
parent75a3f5027f74565d909fb940893636d081d9872a (diff)
add whenM and unlessM
Just more golfing.. I am pretty sure something in a library somewhere can do this, but I have been unable to find it.
Diffstat (limited to 'Command/Migrate.hs')
-rw-r--r--Command/Migrate.hs10
1 files changed, 3 insertions, 7 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index 790d5d365..09ff6df7d 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -8,7 +8,6 @@
module Command.Migrate where
import Control.Monad.State (liftIO)
-import Control.Monad (unless, when)
import System.Posix.Files
import System.Directory
import System.FilePath
@@ -20,6 +19,7 @@ import Locations
import Types
import Content
import Messages
+import Utility
import qualified Command.Add
command :: [Command]
@@ -63,9 +63,7 @@ perform file oldkey newbackend = do
ok <- getViaTmpUnchecked newkey $ \t -> do
-- Make a hard link to the old backend's
-- cached key, to avoid wasting disk space.
- liftIO $ do
- exists <- doesFileExist t
- unless exists $ createLink src t
+ liftIO $ unlessM (doesFileExist t) $ createLink src t
return True
if ok
then do
@@ -74,6 +72,4 @@ perform file oldkey newbackend = do
next $ Command.Add.cleanup file newkey
else stop
where
- cleantmp t = do
- exists <- doesFileExist t
- when exists $ removeFile t
+ cleantmp t = whenM (doesFileExist t) $ removeFile t