diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-12 00:41:48 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-12 00:41:48 -0400 |
commit | 89ee70c43afd12f15c2ee796036f96c620d8becb (patch) | |
tree | ebc0405bccf3f75c2661e24947fdfb575118a038 | |
parent | 83bbb3bc9330de7c4d2b8c07ef48da3bea82433d (diff) |
status: More accurate display of sizes of tmp and bad keys.
Can't trust the key size to be accurate for tmp and bad keys, so check
actual file size. In the wild I saw the old code be wrong by a factor
of about 100!
If all tmp/bad keys are empty, they're not shown in status at all.
Showing 0 bytes and suggesting to clean it up seemed weird..
-rw-r--r-- | Command/Status.hs | 19 | ||||
-rw-r--r-- | debian/changelog | 1 |
2 files changed, 14 insertions, 6 deletions
diff --git a/Command/Status.hs b/Command/Status.hs index 0b1741dc0..96345e92b 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -211,12 +211,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 ++ ")" diff --git a/debian/changelog b/debian/changelog index 120513806..8fc2cc330 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ git-annex (3.20120310) UNRELEASED; urgency=low space, but now only needs to store the set of file contents that are present in the annex in memory. * status: Fixed to run in constant space. + * status: More accurate display of sizes of tmp and bad keys. -- Joey Hess <joeyh@debian.org> Sat, 10 Mar 2012 14:03:22 -0400 |