Book details panel: Dont show sizes less than 0.01MB as zero. Fixes #1882469 [Rounding on file sizes below 5.12 kilobytes](https://bugs.launchpad.net/calibre/+bug/1882469)

This commit is contained in:
Kovid Goyal 2020-06-11 13:57:04 +05:30
parent feabfbf294
commit 8258b394fb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -25,7 +25,10 @@ SIMPLE_SET = frozenset(SIMPLE_GET - {'identifiers'})
def human_readable(size, precision=2):
""" Convert a size in bytes into megabytes """
return ('%.'+unicode_type(precision)+'f'+ 'MB') % (size/(1024*1024),)
ans = size/(1024*1024)
if ans < 0.1:
return '<0.1MB'
return ('%.'+unicode_type(precision)+'f'+ 'MB') % ans
NULL_VALUES = {