Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
4c92fdfb
Commit
4c92fdfb
authored
4 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Fix file path management and download bugs
parent
9dde8391
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
web/app/corpora/views.py
+4
-4
4 additions, 4 deletions
web/app/corpora/views.py
web/app/jobs/views.py
+5
-8
5 additions, 8 deletions
web/app/jobs/views.py
web/app/models.py
+3
-2
3 additions, 2 deletions
web/app/models.py
with
12 additions
and
14 deletions
web/app/corpora/views.py
+
4
−
4
View file @
4c92fdfb
...
@@ -234,7 +234,7 @@ def download_corpus_file(corpus_id, corpus_file_id):
...
@@ -234,7 +234,7 @@ def download_corpus_file(corpus_id, corpus_file_id):
or
current_user
.
is_administrator
()):
or
current_user
.
is_administrator
()):
abort
(
403
)
abort
(
403
)
return
send_from_directory
(
as_attachment
=
True
,
return
send_from_directory
(
as_attachment
=
True
,
directory
=
corpus_file
.
corpus
.
path
,
directory
=
os
.
path
.
dirname
(
corpus_file
.
path
)
,
filename
=
corpus_file
.
filename
)
filename
=
corpus_file
.
filename
)
...
@@ -382,8 +382,7 @@ def inspect_query_result(query_result_id):
...
@@ -382,8 +382,7 @@ def inspect_query_result(query_result_id):
inspect_display_options_form
=
InspectDisplayOptionsForm
(
inspect_display_options_form
=
InspectDisplayOptionsForm
(
prefix
=
'
inspect-display-options-form
'
prefix
=
'
inspect-display-options-form
'
)
)
query_result_file_path
=
os
.
path
.
join
(
query_result
.
path
,
query_result
.
filename
)
# noqa
with
open
(
query_result
.
path
,
'
r
'
)
as
query_result_file
:
with
open
(
query_result_file_path
,
'
r
'
)
as
query_result_file
:
query_result_file_content
=
json
.
load
(
query_result_file
)
query_result_file_content
=
json
.
load
(
query_result_file
)
return
render_template
(
'
corpora/query_results/inspect.html.j2
'
,
return
render_template
(
'
corpora/query_results/inspect.html.j2
'
,
query_result
=
query_result
,
query_result
=
query_result
,
...
@@ -413,5 +412,6 @@ def download_query_result(query_result_id):
...
@@ -413,5 +412,6 @@ def download_query_result(query_result_id):
if
not
(
query_result
.
creator
==
current_user
if
not
(
query_result
.
creator
==
current_user
or
current_user
.
is_administrator
()):
or
current_user
.
is_administrator
()):
abort
(
403
)
abort
(
403
)
return
send_from_directory
(
as_attachment
=
True
,
directory
=
query_result
.
path
,
return
send_from_directory
(
as_attachment
=
True
,
directory
=
os
.
path
.
dirname
(
query_result
.
path
),
filename
=
query_result
.
filename
)
filename
=
query_result
.
filename
)
This diff is collapsed.
Click to expand it.
web/app/jobs/views.py
+
5
−
8
View file @
4c92fdfb
...
@@ -5,6 +5,7 @@ from . import jobs
...
@@ -5,6 +5,7 @@ from . import jobs
from
.
import
tasks
from
.
import
tasks
from
..decorators
import
admin_required
from
..decorators
import
admin_required
from
..models
import
Job
,
JobInput
,
JobResult
from
..models
import
Job
,
JobInput
,
JobResult
import
os
@jobs.route
(
'
/<int:job_id>
'
)
@jobs.route
(
'
/<int:job_id>
'
)
...
@@ -32,14 +33,12 @@ def delete_job(job_id):
...
@@ -32,14 +33,12 @@ def delete_job(job_id):
@jobs.route
(
'
/<int:job_id>/inputs/<int:job_input_id>/download
'
)
@jobs.route
(
'
/<int:job_id>/inputs/<int:job_input_id>/download
'
)
@login_required
@login_required
def
download_job_input
(
job_id
,
job_input_id
):
def
download_job_input
(
job_id
,
job_input_id
):
job_input
=
JobInput
.
query
.
get_or_404
(
job_input_id
)
job_input
=
JobInput
.
query
.
filter
(
JobInput
.
job_id
==
job_id
,
JobInput
.
id
==
job_input_id
).
first_or_404
()
# noqa
if
not
job_input
.
job_id
==
job_id
:
abort
(
404
)
if
not
(
job_input
.
job
.
creator
==
current_user
if
not
(
job_input
.
job
.
creator
==
current_user
or
current_user
.
is_administrator
()):
or
current_user
.
is_administrator
()):
abort
(
403
)
abort
(
403
)
return
send_from_directory
(
as_attachment
=
True
,
return
send_from_directory
(
as_attachment
=
True
,
directory
=
job_input
.
job
.
path
,
directory
=
os
.
path
.
dirname
(
job_input
.
path
)
,
filename
=
job_input
.
filename
)
filename
=
job_input
.
filename
)
...
@@ -59,12 +58,10 @@ def restart(job_id):
...
@@ -59,12 +58,10 @@ def restart(job_id):
@jobs.route
(
'
/<int:job_id>/results/<int:job_result_id>/download
'
)
@jobs.route
(
'
/<int:job_id>/results/<int:job_result_id>/download
'
)
@login_required
@login_required
def
download_job_result
(
job_id
,
job_result_id
):
def
download_job_result
(
job_id
,
job_result_id
):
job_result
=
JobResult
.
query
.
get_or_404
(
job_result_id
)
job_result
=
JobResult
.
query
.
filter
(
JobResult
.
job_id
==
job_id
,
JobResult
.
id
==
job_result_id
).
first_or_404
()
# noqa
if
not
job_result
.
job_id
==
job_id
:
abort
(
404
)
if
not
(
job_result
.
job
.
creator
==
current_user
if
not
(
job_result
.
job
.
creator
==
current_user
or
current_user
.
is_administrator
()):
or
current_user
.
is_administrator
()):
abort
(
403
)
abort
(
403
)
return
send_from_directory
(
as_attachment
=
True
,
return
send_from_directory
(
as_attachment
=
True
,
directory
=
job_result
.
job
.
path
,
directory
=
os
.
path
.
dirname
(
job_result
.
path
)
,
filename
=
job_result
.
filename
)
filename
=
job_result
.
filename
)
This diff is collapsed.
Click to expand it.
web/app/models.py
+
3
−
2
View file @
4c92fdfb
...
@@ -311,7 +311,7 @@ class JobResult(db.Model):
...
@@ -311,7 +311,7 @@ class JobResult(db.Model):
@property
@property
def
path
(
self
):
def
path
(
self
):
return
os
.
path
.
join
(
self
.
job
.
path
,
self
.
filename
)
return
os
.
path
.
join
(
self
.
job
.
path
,
'
output
'
,
self
.
filename
)
def
__repr__
(
self
):
def
__repr__
(
self
):
'''
'''
...
@@ -561,7 +561,8 @@ class QueryResult(db.Model):
...
@@ -561,7 +561,8 @@ class QueryResult(db.Model):
@property
@property
def
path
(
self
):
def
path
(
self
):
return
os
.
path
.
join
(
self
.
creator
.
path
,
'
query_results
'
,
str
(
self
.
id
))
return
os
.
path
.
join
(
self
.
creator
.
path
,
'
query_results
'
,
str
(
self
.
id
),
self
.
filename
)
def
delete
(
self
):
def
delete
(
self
):
shutil
.
rmtree
(
self
.
path
,
ignore_errors
=
True
)
shutil
.
rmtree
(
self
.
path
,
ignore_errors
=
True
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment