mirror of
https://github.com/simon987/nyaa.git
synced 2025-12-14 07:39:03 +00:00
search: allow limiting the maximum number of pages
This commit is contained in:
@@ -372,6 +372,12 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0',
|
||||
if page > 4294967295:
|
||||
flask.abort(404)
|
||||
|
||||
MAX_PAGES = app.config.get("MAX_PAGES", 0)
|
||||
|
||||
if MAX_PAGES and page > MAX_PAGES:
|
||||
flask.abort(flask.Response("You've exceeded the maximum number of pages. Please "
|
||||
"make your search query less broad.", 403))
|
||||
|
||||
sort_keys = {
|
||||
'id': models.Torrent.id,
|
||||
'size': models.Torrent.filesize,
|
||||
@@ -518,6 +524,7 @@ def search_db(term='', user=None, sort='id', order='desc', category='0_0',
|
||||
if rss:
|
||||
query = query.limit(per_page)
|
||||
else:
|
||||
query = query.paginate_faste(page, per_page=per_page, step=5, count_query=count_query)
|
||||
query = query.paginate_faste(page, per_page=per_page, step=5, count_query=count_query,
|
||||
max_page=MAX_PAGES)
|
||||
|
||||
return query
|
||||
|
||||
Reference in New Issue
Block a user