summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2019-12-06 21:06:01 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2019-12-06 21:06:01 +0100
commit909ed54493d6bc9ef225899b53affb3e7da20925 (patch)
tree9bad8f6817afb2085c726018d7fb50a3f1873137
parentaa5f4b19ec567e1e2df2f8c90bcef7c1772b7aa1 (diff)
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.
-rwxr-xr-xfbin/fbin.py6
1 files 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)