From 98fbeba0df112753e0c55b0e2f456cd89ed0ede7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 20 Sep 2011 20:14:17 -0400 Subject: bugfix Different keys can have the same size, so can't make a Set of the sizes. This version actually runs faster yet, too.. --- Command/Status.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Command/Status.hs') diff --git a/Command/Status.hs b/Command/Status.hs index d06865b6a..26122f269 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -147,14 +147,13 @@ cachedKeysReferenced = do keySizeSum :: Set Key -> StatState String keySizeSum s = do - let (sizes, unknownsizes) = S.partition isJust $ S.map keySize s - let total = roughSize storageUnits False $ - fromJust $ S.fold (liftM2 (+)) (Just 0) sizes - let num = S.size unknownsizes + let knownsizes = mapMaybe keySize $ S.toList s + let total = roughSize storageUnits False $ sum knownsizes + let missing = S.size s - genericLength knownsizes return $ total ++ - if num == 0 + if missing == 0 then "" - else aside $ "but " ++ show num ++ " keys have unknown size" + else aside $ "but " ++ show missing ++ " keys have unknown size" staleSize :: String -> (Git.Repo -> FilePath) -> Stat staleSize label dirspec = do -- cgit v1.2.3