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!
This commit is contained in:
parent
894a8948be
commit
3a078ab357
2 changed files with 15 additions and 11 deletions
|
@ -280,17 +280,19 @@ withTmp key action = do
|
||||||
{- Checks that there is disk space available to store a given key,
|
{- Checks that there is disk space available to store a given key,
|
||||||
- in a destination (or the annex) printing a warning if not. -}
|
- in a destination (or the annex) printing a warning if not. -}
|
||||||
checkDiskSpace :: Maybe FilePath -> Key -> Integer -> Annex Bool
|
checkDiskSpace :: Maybe FilePath -> Key -> Integer -> Annex Bool
|
||||||
checkDiskSpace destination key alreadythere = do
|
checkDiskSpace destination key alreadythere = ifM (Annex.getState Annex.force)
|
||||||
reserve <- annexDiskReserve <$> Annex.getGitConfig
|
( return True
|
||||||
free <- liftIO . getDiskFree =<< dir
|
, do
|
||||||
force <- Annex.getState Annex.force
|
reserve <- annexDiskReserve <$> Annex.getGitConfig
|
||||||
case (free, keySize key) of
|
free <- liftIO . getDiskFree =<< dir
|
||||||
(Just have, Just need) -> do
|
case (free, fromMaybe 1 (keySize key)) of
|
||||||
let ok = (need + reserve <= have + alreadythere) || force
|
(Just have, need) -> do
|
||||||
unless ok $
|
let ok = (need + reserve <= have + alreadythere)
|
||||||
needmorespace (need + reserve - have - alreadythere)
|
unless ok $
|
||||||
return ok
|
needmorespace (need + reserve - have - alreadythere)
|
||||||
_ -> return True
|
return ok
|
||||||
|
_ -> return True
|
||||||
|
)
|
||||||
where
|
where
|
||||||
dir = maybe (fromRepo gitAnnexDir) return destination
|
dir = maybe (fromRepo gitAnnexDir) return destination
|
||||||
needmorespace n =
|
needmorespace n =
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -12,6 +12,8 @@ git-annex (5.20150410) UNRELEASED; urgency=medium
|
||||||
* bittorrent: Fix handling of magnet links.
|
* bittorrent: Fix handling of magnet links.
|
||||||
* Windows: Fixed support of remotes on other drives.
|
* Windows: Fixed support of remotes on other drives.
|
||||||
(A reversion introduced in version 5.20150113.)
|
(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
|
-- Joey Hess <id@joeyh.name> Thu, 09 Apr 2015 20:59:43 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue