diff options
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Content.hs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index 9d70ccee3..bbf87880b 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -280,17 +280,19 @@ withTmp key action = do {- Checks that there is disk space available to store a given key, - in a destination (or the annex) printing a warning if not. -} checkDiskSpace :: Maybe FilePath -> Key -> Integer -> Annex Bool -checkDiskSpace destination key alreadythere = do - reserve <- annexDiskReserve <$> Annex.getGitConfig - free <- liftIO . getDiskFree =<< dir - force <- Annex.getState Annex.force - case (free, keySize key) of - (Just have, Just need) -> do - let ok = (need + reserve <= have + alreadythere) || force - unless ok $ - needmorespace (need + reserve - have - alreadythere) - return ok - _ -> return True +checkDiskSpace destination key alreadythere = ifM (Annex.getState Annex.force) + ( return True + , do + reserve <- annexDiskReserve <$> Annex.getGitConfig + free <- liftIO . getDiskFree =<< dir + case (free, fromMaybe 1 (keySize key)) of + (Just have, need) -> do + let ok = (need + reserve <= have + alreadythere) + unless ok $ + needmorespace (need + reserve - have - alreadythere) + return ok + _ -> return True + ) where dir = maybe (fromRepo gitAnnexDir) return destination needmorespace n = |