summaryrefslogtreecommitdiff
path: root/Command/Status.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-03-12 16:32:29 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-03-12 16:32:29 -0400
commit94aff8b8786efb1d396fb20fd0d177fce6056a71 (patch)
tree7ee61a8a74d7ba128d16b1d1c0f0f2b09d56dbfe /Command/Status.hs
parent8540183a02345843a7869521cd65abbe658b4e51 (diff)
parent77fb50e01a8c66f87fdd79c9c4235074a0f55fa7 (diff)
Merge branch 'master' into bloom
Conflicts: debian/changelog
Diffstat (limited to 'Command/Status.hs')
-rw-r--r--Command/Status.hs19
1 files changed, 13 insertions, 6 deletions
diff --git a/Command/Status.hs b/Command/Status.hs
index eadb4f163..39e71e750 100644
--- a/Command/Status.hs
+++ b/Command/Status.hs
@@ -228,12 +228,19 @@ showSizeKeys d = total ++ missingnote
" keys of unknown size"
staleSize :: String -> (Git.Repo -> FilePath) -> Stat
-staleSize label dirspec = do
- keys <- lift (Command.Unused.staleKeys dirspec)
- if null keys
- then nostat
- else stat label $ json (++ aside "clean up with git-annex unused") $
- return $ showSizeKeys $ foldKeys keys
+staleSize label dirspec = go =<< lift (Command.Unused.staleKeys dirspec)
+ where
+ go [] = nostat
+ go keys = onsize =<< sum <$> keysizes keys
+ onsize 0 = nostat
+ onsize size = stat label $
+ json (++ aside "clean up with git-annex unused") $
+ return $ roughSize storageUnits False size
+ keysizes keys = map (fromIntegral . fileSize) <$> stats keys
+ stats keys = do
+ dir <- lift $ fromRepo dirspec
+ liftIO $ forM keys $ \k ->
+ getFileStatus (dir </> keyFile k)
aside :: String -> String
aside s = " (" ++ s ++ ")"