From 8258b394fb53021a97d331cf1560b59726a7cd9c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2020 13:57:04 +0530 Subject: [PATCH] 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) --- src/calibre/ebooks/metadata/book/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/metadata/book/base.py b/src/calibre/ebooks/metadata/book/base.py index ee8df68361..4eafdab282 100644 --- a/src/calibre/ebooks/metadata/book/base.py +++ b/src/calibre/ebooks/metadata/book/base.py @@ -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 = {