From 909ed54493d6bc9ef225899b53affb3e7da20925 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 6 Dec 2019 21:06:01 +0100 Subject: Fix displaying total file size Wrap the call to get_size() in a generator so we don't have to look up the files (if needed) twice. --- fbin/fbin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fbin/fbin.py b/fbin/fbin.py index d1dff76..35fd1fc 100755 --- a/fbin/fbin.py +++ b/fbin/fbin.py @@ -287,7 +287,7 @@ def files(): context = { 'title': 'Files', 'files': files, - 'total_size': db.File.pretty_size(sum(f.size for f in files if f.size)), + 'total_size': db.File.pretty_size(sum(size for size in (f.get_size() for f in files) if size is not None)), } return render_template('files.html', **context) @@ -339,7 +339,7 @@ def images(): 'title': 'Images', 'fullwidth': True, 'files': files, - 'total_size': db.File.pretty_size(sum(f.size for f in files if f.size)), + 'total_size': db.File.pretty_size(sum(size for size in (f.get_size() for f in files) if size is not None)), } return render_template('images.html', **context) @@ -352,7 +352,7 @@ def videos(): 'title': 'Videos', 'fullwidth': True, 'files': files, - 'total_size': db.File.pretty_size(sum(f.size for f in files if f.size)), + 'total_size': db.File.pretty_size(sum(size for size in (f.get_size() for f in files) if size is not None)), } return render_template('images.html', **context) -- cgit v1.2.3