From 21953a802a0f55399288b52834cbfa970fa40d0f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 16 May 2011 22:22:37 -0400 Subject: [PATCH] am I silly to worry about length overflowing int max? --- Command/Status.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Command/Status.hs b/Command/Status.hs index 85a6a5a4be..c2f7692c5f 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -38,10 +38,13 @@ data StatInfo = StatInfo -- a state monad for running Stats in type StatState = StateT StatInfo Annex -type SizeList a = ([a], Int) +-- a list with a known length +-- (Integer is used for the length to avoid +-- blowing up if someone annexed billions of files..) +type SizeList a = ([a], Integer) sizeList :: [a] -> SizeList a -sizeList l = (l, length l) +sizeList l = (l, genericLength l) command :: [Command] command = [repoCommand "status" (paramNothing) seek @@ -163,7 +166,7 @@ keySizeSum :: SizeList Key -> StatState String keySizeSum (keys, len) = do let knownsize = catMaybes $ map keySize keys let total = roughSize storageUnits False $ foldl (+) 0 knownsize - let missing = len - length knownsize + let missing = len - genericLength knownsize return $ total ++ if missing > 0 then " (but " ++ show missing ++ " keys have unknown size)"