Merge pull request #1116 from bookwyrm-social/import-async-error

Don't error when task for import no longer exists
This commit is contained in:
Mouse Reeve 2021-05-20 21:14:15 -07:00 committed by GitHub
commit ea56d42906
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,7 +81,10 @@ class ImportStatus(View):
job = models.ImportJob.objects.get(id=job_id) job = models.ImportJob.objects.get(id=job_id)
if job.user != request.user: if job.user != request.user:
raise PermissionDenied raise PermissionDenied
try:
task = app.AsyncResult(job.task_id) task = app.AsyncResult(job.task_id)
except ValueError:
task = None
items = job.items.order_by("index").all() items = job.items.order_by("index").all()
failed_items = [i for i in items if i.fail_reason] failed_items = [i for i in items if i.fail_reason]
items = [i for i in items if not i.fail_reason] items = [i for i in items if not i.fail_reason]