diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-21 21:55:02 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-21 21:55:02 -0400 |
commit | 188e2edc41551fa145d6cb8b36838fcb85132088 (patch) | |
tree | a0f99daac3b86c5b886779aed5cad95729d65684 /Config.hs | |
parent | 181d2ccd20a41b1785569acb3efb76deb8cbdf00 (diff) |
status: Prints available local disk space, or shows if git-annex doesn't know.
Diffstat (limited to 'Config.hs')
-rw-r--r-- | Config.hs | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -12,6 +12,8 @@ import qualified Git import qualified Git.Config import qualified Git.Command import qualified Annex +import qualified Build.SysConfig +import Utility.DataUnits type ConfigKey = String @@ -85,3 +87,22 @@ getNumCopies v = perhaps (use v) =<< Annex.getState Annex.forcenumcopies {- Gets the trust level set for a remote in git config. -} getTrustLevel :: Git.Repo -> Annex (Maybe String) getTrustLevel r = fromRepo $ Git.Config.getMaybe $ remoteConfig r "trustlevel" + +{- Gets annex.diskreserve setting. -} +getDiskReserve :: Bool -> Annex Integer +getDiskReserve sanitycheck = do + g <- gitRepo + r <- getConfig g "diskreserve" "" + when sanitycheck $ check r + return $ fromMaybe megabyte $ readSize dataUnits r + where + megabyte = 1000000 + check r + | not (null r) && not cancheck = do + unlessM (Annex.getState Annex.force) $ + error $ "You have configured a diskreserve of " + ++ r ++ + " but disk space checking is not working" + return () + | otherwise = return () + cancheck = Build.SysConfig.statfs_sanity_checked == Just True |