summaryrefslogtreecommitdiff
path: root/Remote
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 /Remote
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 'Remote')
-rw-r--r--Remote/Bup.hs9
-rw-r--r--Remote/Directory.hs4
-rw-r--r--Remote/Rsync.hs7
3 files changed, 9 insertions, 11 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index d2b771bf7..51a5d05d1 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -11,7 +11,7 @@ import qualified Data.ByteString.Lazy.Char8 as L
import IO
import Control.Exception.Extensible (IOException)
import qualified Data.Map as M
-import Control.Monad (unless, when)
+import Control.Monad (when)
import Control.Monad.State (liftIO)
import System.Process
import System.Exit
@@ -75,8 +75,7 @@ bupSetup u c = do
-- bup init will create the repository.
-- (If the repository already exists, bup init again appears safe.)
showNote "bup init"
- ok <- bup "init" buprepo []
- unless ok $ error "bup init failed"
+ bup "init" buprepo [] <|> error "bup init failed"
storeBupUUID u buprepo
@@ -172,9 +171,9 @@ storeBupUUID u buprepo = do
if Git.repoIsUrl r
then do
showNote "storing uuid"
- ok <- onBupRemote r boolSystem "git"
+ onBupRemote r boolSystem "git"
[Params $ "config annex.uuid " ++ u]
- unless ok $ do error "ssh failed"
+ <|> error "ssh failed"
else liftIO $ do
r' <- Git.configRead r
let olduuid = Git.configGet r' "annex.uuid" ""
diff --git a/Remote/Directory.hs b/Remote/Directory.hs
index 0cd3760d6..f69aa1256 100644
--- a/Remote/Directory.hs
+++ b/Remote/Directory.hs
@@ -62,8 +62,8 @@ directorySetup u c = do
-- verify configuration is sane
let dir = maybe (error "Specify directory=") id $
M.lookup "directory" c
- e <- liftIO $ doesDirectoryExist dir
- when (not e) $ error $ "Directory does not exist: " ++ dir
+ liftIO $ doesDirectoryExist dir
+ <|> error $ "Directory does not exist: " ++ dir
c' <- encryptionSetup c
-- The directory is stored in git config, not in this remote's
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs
index c15ab37a7..53418a9ef 100644
--- a/Remote/Rsync.hs
+++ b/Remote/Rsync.hs
@@ -10,7 +10,7 @@ module Remote.Rsync (remote) where
import qualified Data.ByteString.Lazy.Char8 as L
import Control.Exception.Extensible (IOException)
import qualified Data.Map as M
-import Control.Monad.State (liftIO, when)
+import Control.Monad.State (liftIO)
import System.FilePath
import System.Directory
import System.Posix.Files
@@ -168,9 +168,8 @@ withRsyncScratchDir a = do
nuke tmp
return res
where
- nuke d = liftIO $ do
- e <- doesDirectoryExist d
- when e $ liftIO $ removeDirectoryRecursive d
+ nuke d = liftIO $
+ doesDirectoryExist d <&> removeDirectoryRecursive d
rsyncRemote :: RsyncOpts -> [CommandParam] -> Annex Bool
rsyncRemote o params = do