Merge pull request #2367 from phw/handle-invalid-filesize

Handle exceptions if ~filesize is not numeric
This commit is contained in:
Laurent Monin
2024-01-29 01:40:39 +01:00
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -826,7 +826,10 @@ class File(QtCore.QObject, Item):
if not value and not get_config().setting['clear_existing_tags']:
value = self.orig_metadata[column]
if column == '~filesize':
value = bytes2human.binary(value)
try:
value = bytes2human.binary(value)
except ValueError:
pass
return value
def _lookup_finished(self, lookuptype, document, http, error):

View File

@@ -287,7 +287,10 @@ def format_file_info(file_):
info.append((_("Format:"), file_.orig_metadata['~format']))
if '~filesize' in file_.orig_metadata:
size = file_.orig_metadata['~filesize']
sizestr = "%s (%s)" % (bytes2human.decimal(size), bytes2human.binary(size))
try:
sizestr = "%s (%s)" % (bytes2human.decimal(size), bytes2human.binary(size))
except ValueError:
sizestr = _("unknown")
info.append((_("Size:"), sizestr))
if file_.orig_metadata.length:
info.append((_("Length:"), format_time(file_.orig_metadata.length)))