Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
06b0c83c
Commit
06b0c83c
authored
Sep 20, 2018
by
Markus Scheidgen
Browse files
Fixed content-encoding on archive api with gzipped archives.
parent
99257551
Changes
3
Hide whitespace changes
Inline
Side-by-side
nomad/api.py
View file @
06b0c83c
...
...
@@ -644,7 +644,17 @@ def get_calc(upload_hash, calc_hash):
try
:
archive
=
ArchiveFile
(
archive_id
)
arhchive_path
=
archive
.
os_path
return
send_file
(
arhchive_path
,
attachment_filename
=
os
.
path
.
basename
(
arhchive_path
))
rv
=
send_file
(
arhchive_path
,
mimetype
=
'application/json'
,
as_attachment
=
True
,
attachment_filename
=
os
.
path
.
basename
(
arhchive_path
))
if
config
.
files
.
compress_archive
:
rv
.
headers
[
'Content-Encoding'
]
=
'gzip'
return
rv
except
KeyError
:
abort
(
404
,
message
=
'Archive %s does not exist.'
%
archive_id
)
except
FileNotFoundError
:
...
...
tests/test_api.py
View file @
06b0c83c
import
pytest
import
time
import
json
import
zlib
import
re
from
mongoengine
import
connect
from
mongoengine.connection
import
disconnect
...
...
@@ -153,7 +154,7 @@ def test_processing(client, file, mode, worker, mocksearch, test_user_auth, no_w
upload_id
=
upload
[
'upload_id'
]
upload_cmd
=
upload
[
'upload_command'
]
headers
=
dict
(
Authorization
=
'Basic %s'
%
re
.
search
(
r
'.*
-H
Authorization: Basic ([^\s]+).*'
,
upload_cmd
).
group
(
1
))
headers
=
dict
(
Authorization
=
'Basic %s'
%
re
.
search
(
r
'.*Authorization: Basic ([^\s]+).*'
,
upload_cmd
).
group
(
1
))
upload_endpoint
=
'/uploads/%s'
%
upload_id
upload_file_endpoint
=
'%s/file'
%
upload_endpoint
...
...
@@ -266,6 +267,12 @@ def test_repo_calcs_user_invisible(client, example_elastic_calc, test_other_user
def
test_get_archive
(
client
,
archive
,
no_warn
):
rv
=
client
.
get
(
'/archive/%s'
%
archive
.
object_id
)
if
rv
.
headers
.
get
(
'Content-Encoding'
)
==
'gzip'
:
json
.
loads
(
zlib
.
decompress
(
rv
.
data
,
16
+
zlib
.
MAX_WBITS
))
else
:
json
.
loads
(
rv
.
data
)
assert
rv
.
status_code
==
200
...
...
tests/test_files.py
View file @
06b0c83c
...
...
@@ -75,7 +75,7 @@ def archive_config(monkeypatch, request):
config
.
files
.
uploads_bucket
,
config
.
files
.
repository_bucket
,
config
.
files
.
archive_bucket
,
request
)
request
.
param
)
monkeypatch
.
setattr
(
config
,
'files'
,
new_config
)
yield
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment