summaryrefslogtreecommitdiff
path: root/Content.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-22 17:53:40 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-22 17:53:40 -0400
commit368e20eb84fac8224a2ab33616cdd31f2c4d5ff1 (patch)
treecfbaf0fac1cf44bb0a8f62cebe12c51a6573fab2 /Content.hs
parentc21998722cb6a65993a3b72e66b225443cfce48b (diff)
diskreserve setting
Add annex.diskreserve config setting, to control how much free space to reserve for other purposes and avoid using (defaults to 1 mb).
Diffstat (limited to 'Content.hs')
-rw-r--r--Content.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/Content.hs b/Content.hs
index 596274ad0..39a3addcc 100644
--- a/Content.hs
+++ b/Content.hs
@@ -119,24 +119,23 @@ checkDiskSpace = checkDiskSpace' 0
checkDiskSpace' :: Integer -> Key -> Annex ()
checkDiskSpace' adjustment key = do
- liftIO $ putStrLn $ "adjust " ++ show adjustment
g <- Annex.gitRepo
+ r <- Annex.repoConfig g "diskreserve" ""
+ let reserve = if null r then megabyte else (read r :: Integer)
stats <- liftIO $ getFileSystemStats (gitAnnexDir g)
case (stats, keySize key) of
(Nothing, _) -> return ()
(_, Nothing) -> return ()
(Just (FileSystemStats { fsStatBytesAvailable = have }), Just need) ->
- if (need + overhead >= have + adjustment)
+ if (need + reserve > have + adjustment)
then error $ "not enough free space (have " ++
showsize (have + adjustment) ++ "; need " ++
- showsize (need + overhead) ++ ")"
+ showsize (need + reserve) ++ ")"
else return ()
where
showsize i = show i
- -- Adding a file to the annex requires some overhead beyond
- -- just the file size; the git index must be updated, etc.
- -- This is an arbitrary value.
- overhead = 1024 * 1024 -- 1 mb
+ megabyte :: Integer
+ megabyte = 1024 * 1024
{- Removes the write bits from a file. -}
preventWrite :: FilePath -> IO ()