diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 15734212..ea911bd0 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -3772,16 +3772,17 @@ class MasterView(View): return tags.link_to(content, url) return content - def readable_size(self, path): + def readable_size(self, path, size=None): # TODO: this was shamelessly copied from FormAlchemy ... - length = self.get_size(path) - if length == 0: + if size is None: + size = self.get_size(path) + if size == 0: return '0 KB' - if length <= 1024: + if size <= 1024: return '1 KB' - if length > 1048576: - return '%0.02f MB' % (length / 1048576.0) - return '%0.02f KB' % (length / 1024.0) + if size > 1048576: + return '%0.02f MB' % (size / 1048576.0) + return '%0.02f KB' % (size / 1024.0) def get_size(self, path): try: