mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-27 00:10:35 +00:00
Fix file path management and download bugs
This commit is contained in:
@ -5,6 +5,7 @@ from . import jobs
|
||||
from . import tasks
|
||||
from ..decorators import admin_required
|
||||
from ..models import Job, JobInput, JobResult
|
||||
import os
|
||||
|
||||
|
||||
@jobs.route('/<int:job_id>')
|
||||
@ -32,14 +33,12 @@ def delete_job(job_id):
|
||||
@jobs.route('/<int:job_id>/inputs/<int:job_input_id>/download')
|
||||
@login_required
|
||||
def download_job_input(job_id, job_input_id):
|
||||
job_input = JobInput.query.get_or_404(job_input_id)
|
||||
if not job_input.job_id == job_id:
|
||||
abort(404)
|
||||
job_input = JobInput.query.filter(JobInput.job_id == job_id, JobInput.id == job_input_id).first_or_404() # noqa
|
||||
if not (job_input.job.creator == current_user
|
||||
or current_user.is_administrator()):
|
||||
abort(403)
|
||||
return send_from_directory(as_attachment=True,
|
||||
directory=job_input.job.path,
|
||||
directory=os.path.dirname(job_input.path),
|
||||
filename=job_input.filename)
|
||||
|
||||
|
||||
@ -59,12 +58,10 @@ def restart(job_id):
|
||||
@jobs.route('/<int:job_id>/results/<int:job_result_id>/download')
|
||||
@login_required
|
||||
def download_job_result(job_id, job_result_id):
|
||||
job_result = JobResult.query.get_or_404(job_result_id)
|
||||
if not job_result.job_id == job_id:
|
||||
abort(404)
|
||||
job_result = JobResult.query.filter(JobResult.job_id == job_id, JobResult.id == job_result_id).first_or_404() # noqa
|
||||
if not (job_result.job.creator == current_user
|
||||
or current_user.is_administrator()):
|
||||
abort(403)
|
||||
return send_from_directory(as_attachment=True,
|
||||
directory=job_result.job.path,
|
||||
directory=os.path.dirname(job_result.path),
|
||||
filename=job_result.filename)
|
||||
|
Reference in New Issue
Block a user