summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-03-21 21:55:02 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-03-21 21:55:02 -0400
commit188e2edc41551fa145d6cb8b36838fcb85132088 (patch)
treea0f99daac3b86c5b886779aed5cad95729d65684 /Command
parent181d2ccd20a41b1785569acb3efb76deb8cbdf00 (diff)
status: Prints available local disk space, or shows if git-annex doesn't know.
Diffstat (limited to 'Command')
-rw-r--r--Command/Status.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/Command/Status.hs b/Command/Status.hs
index 39e71e750..576c3bba6 100644
--- a/Command/Status.hs
+++ b/Command/Status.hs
@@ -22,12 +22,15 @@ import qualified Git
import qualified Annex
import Command
import Utility.DataUnits
+import Utility.StatFS
import Annex.Content
import Types.Key
import Backend
import Logs.UUID
import Logs.Trust
import Remote
+import Config
+import qualified Build.SysConfig
-- a named computation that produces a statistic
type Stat = StatState (Maybe (String, StatState String))
@@ -76,6 +79,7 @@ slow_stats =
, local_annex_size
, known_annex_keys
, known_annex_size
+ , disk_size
, bloom_info
, backend_usage
]
@@ -157,6 +161,23 @@ known_annex_size :: Stat
known_annex_size = stat "known annex size" $ json id $
showSizeKeys <$> cachedReferencedData
+disk_size :: Stat
+disk_size = stat "available local disk space" $ json id $ lift go
+ where
+ go
+ | Build.SysConfig.statfs_sanity_checked == Just True =
+ calcfree
+ <$> getDiskReserve False
+ <*> inRepo (getFileSystemStats . gitAnnexDir)
+ | otherwise = return unknown
+ calcfree reserve (Just (FileSystemStats { fsStatBytesAvailable = have })) =
+ roughSize storageUnits True $ unreserved reserve have
+ calcfree _ _ = unknown
+ unreserved reserve have
+ | have >= reserve = have - reserve
+ | otherwise = 0
+ unknown = "unknown"
+
known_annex_keys :: Stat
known_annex_keys = stat "known annex keys" $ json show $
countKeys <$> cachedReferencedData