Skip to content

Commit

Permalink
Handle exceptions if ~filesize is not numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Jan 28, 2024
1 parent f19818c commit 3025e68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion picard/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,10 @@ def column(self, column):
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):
Expand Down
5 changes: 4 additions & 1 deletion picard/ui/infodialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 3025e68

Please sign in to comment.