summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-17 21:29:15 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-17 21:29:15 -0400
commita5426f14cac3c64299cac62ee6fe86a35f41f584 (patch)
treebf3f3ddcc57bc9b0010277348dbfd850b6d345c1
parentf4e1fe5508d4a2de6a777af371457586439493ed (diff)
When a key's size is unknown, still check the annex.diskreserve, and avoid getting content if the disk is too full.
We can't check if there's enough disk space to download the content, but we *can* check if there's certainly not enough!
-rw-r--r--Annex/Content.hs24
-rw-r--r--debian/changelog2
2 files changed, 15 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 =
diff --git a/debian/changelog b/debian/changelog
index 5f62dc62c..8bbadfea2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,8 @@ git-annex (5.20150410) UNRELEASED; urgency=medium
* bittorrent: Fix handling of magnet links.
* Windows: Fixed support of remotes on other drives.
(A reversion introduced in version 5.20150113.)
+ * When a key's size is unknown, still check the annex.diskreserve,
+ and avoid getting content if the disk is too full.
-- Joey Hess <id@joeyh.name> Thu, 09 Apr 2015 20:59:43 -0400