diff --git a/Backend.hs b/Backend.hs index fe61739e83..0ee56d2623 100644 --- a/Backend.hs +++ b/Backend.hs @@ -192,15 +192,7 @@ checkKeySize key = do then return True else do dest <- moveBad key - warning $ badsizeNote dest size size' + warning $ "Bad file size (" ++ + compareSizes True size size' ++ + "); moved to " ++ dest return False - -badsizeNote :: FilePath -> Integer -> Integer -> String -badsizeNote dest expected got = "Bad file size (" ++ aside ++ "); moved to " ++ dest - where - expected' = roughSize True expected - got' = roughSize True got - aside = - if expected' == got' - then show got ++ " not " ++ show expected - else got' ++ " not " ++ expected' diff --git a/DataUnits.hs b/DataUnits.hs index 329bf7e580..c2845affea 100644 --- a/DataUnits.hs +++ b/DataUnits.hs @@ -5,7 +5,7 @@ - Licensed under the GNU GPL version 3 or higher. -} -module DataUnits (roughSize) where +module DataUnits (roughSize, compareSizes) where {- And now a rant: - @@ -63,3 +63,9 @@ roughSize short i plural n u | n == 1 = u | otherwise = u ++ "s" + +compareSizes :: Bool -> Integer -> Integer -> String +compareSizes short old new + | old > new = roughSize short (old - new) ++ " smaller" + | old < new = roughSize short (new - old) ++ " larger" + | otherwise = "same"