diff --git a/app/blueprints/zipgrep/__init__.py b/app/blueprints/zipgrep/__init__.py index e80d2575..df99b1ed 100644 --- a/app/blueprints/zipgrep/__init__.py +++ b/app/blueprints/zipgrep/__init__.py @@ -16,7 +16,7 @@ from celery import uuid -from flask import Blueprint, render_template, redirect, request +from flask import Blueprint, render_template, redirect, request, abort from flask_wtf import FlaskForm from wtforms import StringField, BooleanField, SubmitField from wtforms.validators import InputRequired, Length @@ -53,6 +53,9 @@ def zipgrep_search(): @bp.route("/zipgrep//") def view_results(id): result = celery.AsyncResult(id) + if result.status == "PENDING": + abort(404) + if result.status != "SUCCESS" or isinstance(result.result, Exception): result_url = url_for("zipgrep.view_results", id=id) return redirect(url_for("tasks.check", id=id, r=result_url)) diff --git a/app/templates/zipgrep/view_results.html b/app/templates/zipgrep/view_results.html index 08df29dd..49f1f8ce 100644 --- a/app/templates/zipgrep/view_results.html +++ b/app/templates/zipgrep/view_results.html @@ -10,7 +10,7 @@

{{ query }}

- Found in {{ matches | count }} packages. + Found in {{ matches | count }} package(s).

@@ -30,7 +30,7 @@

- {{ match.lines.split("\n") | select | list | count }} matches + {{ match.lines.split("\n") | select | list | count }} match(es)