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.
This commit is contained in:
parent
75a3f5027f
commit
c91929f693
16 changed files with 60 additions and 63 deletions
|
@ -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)"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue