summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-16 22:22:37 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-16 22:22:37 -0400
commit21953a802a0f55399288b52834cbfa970fa40d0f (patch)
treeb81cfd9c597fb4e287c0fc6a8b8d8c19499747fc
parent5068985020a4fbd699721cd506250316c55f129f (diff)
am I silly to worry about length overflowing int max?
-rw-r--r--Command/Status.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/Command/Status.hs b/Command/Status.hs
index 85a6a5a4b..c2f7692c5 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)"