diff --git a/app/models.py b/app/models.py index 73a8565b..f8e6fbc6 100644 --- a/app/models.py +++ b/app/models.py @@ -297,6 +297,7 @@ class Job(db.Model): end_date = db.Column(db.DateTime()) mem_mb = db.Column(db.Integer) n_cores = db.Column(db.Integer) + secure_filename = db.Column(db.String(32)) service = db.Column(db.String(64)) ''' ' Service specific arguments as string list. @@ -323,8 +324,7 @@ class Job(db.Model): """ Takes the job.title string nad cratesa a secure filename from this. """ - filename = secure_filename(self.title) - return filename + self.secure_filename = secure_filename(self.title) def delete(self): """ diff --git a/app/services/views.py b/app/services/views.py index e56babdd..1605f666 100644 --- a/app/services/views.py +++ b/app/services/views.py @@ -37,12 +37,9 @@ def service(service): return make_response(add_job_form.errors, 400) service_args = [] if service == 'nlp': - logger.warning(add_job_form.check_encoding) service_args.append('-l {}'.format(add_job_form.language.data)) - logger.warning("Service args: {}".format(service_args)) if add_job_form.check_encoding.data: service_args.append('--check-encoding') - logger.warning("Service args: {}".format(service_args)) if service == 'ocr': service_args.append('-l {}'.format(add_job_form.language.data)) if not add_job_form.binarization.data: @@ -54,6 +51,8 @@ def service(service): service=service, service_args=json.dumps(service_args), service_version=add_job_form.version.data, status='preparing', title=add_job_form.title.data) + if job.service != 'corpus_analysis': + job.create_secure_filename() db.session.add(job) db.session.commit() relative_dir = os.path.join(str(job.user_id), 'jobs', str(job.id)) diff --git a/migrations/versions/7378391345fa_.py b/migrations/versions/7378391345fa_.py new file mode 100644 index 00000000..133046a2 --- /dev/null +++ b/migrations/versions/7378391345fa_.py @@ -0,0 +1,28 @@ +"""empty message + +Revision ID: 7378391345fa +Revises: 6227310c2112 +Create Date: 2020-02-17 12:29:17.851954 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '7378391345fa' +down_revision = '6227310c2112' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('jobs', sa.Column('secure_filename', sa.String(length=32), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('jobs', 'secure_filename') + # ### end Alembic commands ###