Fix minor issues with zipgrep

This commit is contained in:
rubenwardy 2022-04-09 01:41:38 +01:00
parent f137dfa978
commit 64acf3047f
2 changed files with 6 additions and 3 deletions

@ -16,7 +16,7 @@
from celery import uuid 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 flask_wtf import FlaskForm
from wtforms import StringField, BooleanField, SubmitField from wtforms import StringField, BooleanField, SubmitField
from wtforms.validators import InputRequired, Length from wtforms.validators import InputRequired, Length
@ -53,6 +53,9 @@ def zipgrep_search():
@bp.route("/zipgrep/<id>/") @bp.route("/zipgrep/<id>/")
def view_results(id): def view_results(id):
result = celery.AsyncResult(id) result = celery.AsyncResult(id)
if result.status == "PENDING":
abort(404)
if result.status != "SUCCESS" or isinstance(result.result, Exception): if result.status != "SUCCESS" or isinstance(result.result, Exception):
result_url = url_for("zipgrep.view_results", id=id) result_url = url_for("zipgrep.view_results", id=id)
return redirect(url_for("tasks.check", id=id, r=result_url)) return redirect(url_for("tasks.check", id=id, r=result_url))

@ -10,7 +10,7 @@
<h2>{{ query }}</h2> <h2>{{ query }}</h2>
<p class="text-muted"> <p class="text-muted">
Found in {{ matches | count }} packages. Found in {{ matches | count }} package(s).
</p> </p>
<div class="list-group"> <div class="list-group">
@ -30,7 +30,7 @@
</div> </div>
<p class="mt-4"> <p class="mt-4">
{{ match.lines.split("\n") | select | list | count }} matches {{ match.lines.split("\n") | select | list | count }} match(es)
</p> </p>
<a class="mt-4 btn btn-secondary" href="{{ match.package.getDownloadRelease().getDownloadURL() }}"> <a class="mt-4 btn btn-secondary" href="{{ match.package.getDownloadRelease().getDownloadURL() }}">