diff options
author | Joey Hess <joey@kitenet.net> | 2011-05-17 03:10:13 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-05-17 03:13:11 -0400 |
commit | c91929f6934fc4e94603d0fa004e824d5e2cfb65 (patch) | |
tree | e958f5b4dc1209afb90c786493164c351dea4b9a /Content.hs | |
parent | 75a3f5027f74565d909fb940893636d081d9872a (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 'Content.hs')
-rw-r--r-- | Content.hs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Content.hs b/Content.hs index 0758fcdb1..ec7a3776b 100644 --- a/Content.hs +++ b/Content.hs @@ -134,8 +134,7 @@ withTmp key action = do let tmp = gitAnnexTmpLocation g key liftIO $ createDirectoryIfMissing True (parentDir tmp) res <- action tmp - tmp_exists <- liftIO $ doesFileExist tmp - when tmp_exists $ liftIO $ removeFile tmp + liftIO $ whenM (doesFileExist tmp) $ liftIO $ removeFile tmp return res {- Checks that there is disk space available to store a given key, @@ -160,8 +159,7 @@ checkDiskSpace' adjustment key = do megabyte :: Integer megabyte = 1000000 needmorespace n = do - force <- Annex.getState Annex.force - unless force $ + unlessM (Annex.getState Annex.force) $ error $ "not enough free space, need " ++ roughSize storageUnits True n ++ " more (use --force to override this check or adjust annex.diskreserve)" |