diff --git a/BUGs b/BUGs
index 0ced882..ed09163 100644
--- a/BUGs
+++ b/BUGs
@@ -28,5 +28,4 @@ Traceback (most recent call last):
self.url = pref.orig_url
AttributeError: 'NoneType' object has no attribute 'orig_url'
-BUG-121: when search cannot find a match it assumes one and barfs
BUG-122: Two versions of Ian and of Micky?
diff --git a/files.py b/files.py
index 29d722d..efe360d 100644
--- a/files.py
+++ b/files.py
@@ -283,6 +283,9 @@ def GetEntriesInSearchView( OPT ):
with db.engine.connect() as conn:
OPT.num_entries = conn.execute( text( num_e_sql ) ).first().count
+ if OPT.num_entries == 0:
+ return []
+
last_entry_sql= f"{sel_no_order} order by {OPT.last_order_raw} limit 1"
with db.engine.connect() as conn:
OPT.last_eid = conn.execute( text( last_entry_sql ) ).first().id
diff --git a/templates/files.html b/templates/files.html
index b354a16..888619a 100644
--- a/templates/files.html
+++ b/templates/files.html
@@ -66,7 +66,7 @@
{{OPT.how_many}} files
{% set nxt_disabled="" %}
- {% if entry_data|length < OPT.how_many|int %}
+ {% if entry_data and entry_data|length < OPT.how_many|int %}
{% set nxt_disabled="disabled" %}
{% endif %}