Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
d73d430b
Commit
d73d430b
authored
7 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add db update and tests
parent
0ceb33a8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/database.py
+23
-1
23 additions, 1 deletion
bin/database.py
test/integration_tests/python/test_uploads.py
+6
-0
6 additions, 0 deletions
test/integration_tests/python/test_uploads.py
with
29 additions
and
1 deletion
bin/database.py
+
23
−
1
View file @
d73d430b
...
...
@@ -14,6 +14,7 @@ import sys
import
time
from
api
import
config
from
api
import
util
from
api.dao
import
containerutil
from
api.dao.containerstorage
import
ProjectStorage
from
api.jobs.jobs
import
Job
...
...
@@ -21,7 +22,7 @@ from api.jobs import gears
from
api.types
import
Origin
from
api.jobs
import
batch
CURRENT_DATABASE_VERSION
=
3
5
# An int that is bumped when a new schema change is made
CURRENT_DATABASE_VERSION
=
3
6
# An int that is bumped when a new schema change is made
def
get_db_version
():
...
...
@@ -1189,6 +1190,27 @@ def upgrade_to_35():
process_cursor
(
cursor
,
upgrade_to_35_closure
)
def
upgrade_to_36_closure
(
acquisition
):
for
f
in
acquisition
[
'
files
'
]:
if
not
f
.
get
(
'
mimetype
'
):
logging
.
debug
(
'
file with name {} did not have mimetype
'
.
format
(
f
[
'
name
'
]))
f
[
'
mimetype
'
]
=
util
.
guess_mimetype
(
f
[
'
name
'
])
result
=
config
.
db
.
acquisitions
.
update_one
({
'
_id
'
:
acquisition
[
'
_id
'
]},
{
'
$set
'
:
{
'
files
'
:
acquisition
[
'
files
'
]}})
if
result
.
modified_count
!=
1
:
raise
Exception
(
'
Acquisition file not updated
'
)
return
True
def
upgrade_to_36
():
"""
scitran/core issue #931 - mimetype not set on packfile uploads
"""
cursor
=
config
.
db
.
acquisitions
.
find
({
'
files.mimetype
'
:
None
})
process_cursor
(
cursor
,
upgrade_to_36_closure
)
###
...
...
This diff is collapsed.
Click to expand it.
test/integration_tests/python/test_uploads.py
+
6
−
0
View file @
d73d430b
...
...
@@ -932,6 +932,12 @@ def test_packfile_upload(data_builder, file_form, as_admin, as_root, api_db):
params
=
{
'
token
'
:
token
,
'
metadata
'
:
metadata_json
})
assert
r
.
ok
# make sure file was uploaded and mimetype and type are properly set
packfile
=
as_admin
.
get
(
'
/acquisitions
'
).
json
()[
0
][
'
files
'
][
0
]
assert
packfile
[
'
mimetype
'
]
==
'
application/zip
'
assert
packfile
[
'
type
'
]
==
'
test
'
# get another token (start packfile-upload)
r
=
as_admin
.
post
(
'
/projects/
'
+
project
+
'
/packfile-start
'
)
assert
r
.
ok
...
...
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