diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d0d5b4001d..b8d1112d2210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Users don't have access to a task object anymore if they are assigneed only on some jobs of the task () - Different resources (tasks, projects) are not visible anymore for all CVAT instance users by default () +- Replaced 'django_sendfile' with 'django_sendfile2' () ### Deprecated - Job field "status" is not used in UI anymore, but it has not been removed from the database yet () diff --git a/Dockerfile b/Dockerfile index 689a48b7d108..3b170bdd75a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ RUN curl -sL https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 --outp # Install requirements RUN python3 -m venv /opt/venv ENV PATH="/opt/venv/bin:${PATH}" -RUN python3 -m pip install --no-cache-dir -U pip==21.0.1 setuptools==53.0.0 wheel==0.36.2 +RUN python3 -m pip install --no-cache-dir -U pip==22.0.2 setuptools==60.6.0 wheel==0.37.1 COPY cvat/requirements/ /tmp/requirements/ RUN DATUMARO_HEADLESS=1 python3 -m pip install --no-cache-dir -r /tmp/requirements/${DJANGO_CONFIGURATION}.txt diff --git a/cvat/apps/engine/backup.py b/cvat/apps/engine/backup.py index 50b47cbb536b..19deec38838c 100644 --- a/cvat/apps/engine/backup.py +++ b/cvat/apps/engine/backup.py @@ -21,7 +21,7 @@ from rest_framework.parsers import JSONParser from rest_framework.renderers import JSONRenderer from rest_framework.response import Response -from sendfile import sendfile +from django_sendfile import sendfile import cvat.apps.dataset_manager as dm from cvat.apps.engine import models diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index 50cf67cb4b0b..c76ed7c4b91f 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -35,7 +35,7 @@ from rest_framework.renderers import JSONRenderer from rest_framework.response import Response from rest_framework.exceptions import PermissionDenied -from sendfile import sendfile +from django_sendfile import sendfile import cvat.apps.dataset_manager as dm import cvat.apps.dataset_manager.views # pylint: disable=unused-import diff --git a/cvat/apps/opencv/views.py b/cvat/apps/opencv/views.py index 8e493fea169d..d0b3b2652dc5 100644 --- a/cvat/apps/opencv/views.py +++ b/cvat/apps/opencv/views.py @@ -1,7 +1,7 @@ import os import glob from django.conf import settings -from sendfile import sendfile +from django_sendfile import sendfile def OpenCVLibrary(request): dirname = os.path.join(settings.STATIC_ROOT, 'opencv', 'js') diff --git a/cvat/requirements/base.txt b/cvat/requirements/base.txt index a3adadc8b00b..cd8ca7feb0f3 100644 --- a/cvat/requirements/base.txt +++ b/cvat/requirements/base.txt @@ -18,7 +18,7 @@ requests==2.26.0 rq==1.5.1 rq-scheduler==0.10.0 sqlparse==0.4.2 -django-sendfile==0.3.11 +django-sendfile2==0.6.1 dj-pagination==2.5.0 python-logstash-async==2.2.0 django-revproxy==0.10.0 diff --git a/cvat/settings/base.py b/cvat/settings/base.py index c7593eaa3007..d8db3e86b43c 100644 --- a/cvat/settings/base.py +++ b/cvat/settings/base.py @@ -106,7 +106,7 @@ def add_ssh_keys(): 'django.contrib.staticfiles', 'django_rq', 'compressor', - 'sendfile', + 'django_sendfile', 'dj_pagination', 'revproxy', 'rest_framework', @@ -498,3 +498,8 @@ def add_ssh_keys(): # More about forwarded headers - https://doc.traefik.io/traefik/getting-started/faq/#what-are-the-forwarded-headers-when-proxying-http-requests # How django uses X-Forwarded-Proto - https://docs.djangoproject.com/en/2.2/ref/settings/#secure-proxy-ssl-header SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + + +# Django-sendfile requires to set SENDFILE_ROOT +# https://github.com/moggers87/django-sendfile2 +SENDFILE_ROOT = BASE_DIR diff --git a/cvat/settings/development.py b/cvat/settings/development.py index 43edc986390a..c0a920fe1951 100644 --- a/cvat/settings/development.py +++ b/cvat/settings/development.py @@ -14,8 +14,8 @@ ALLOWED_HOSTS.append('testserver') # Django-sendfile: -# https://github.com/johnsensible/django-sendfile -SENDFILE_BACKEND = 'sendfile.backends.development' +# https://github.com/moggers87/django-sendfile2 +SENDFILE_BACKEND = 'django_sendfile.backends.development' # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases diff --git a/cvat/settings/production.py b/cvat/settings/production.py index 5b6b4a921ddd..b12b9f165fc9 100644 --- a/cvat/settings/production.py +++ b/cvat/settings/production.py @@ -16,8 +16,8 @@ RQ_QUEUES[key]['HOST'] = os.getenv('CVAT_REDIS_HOST', 'cvat_redis') # Django-sendfile: -# https://github.com/johnsensible/django-sendfile -SENDFILE_BACKEND = 'sendfile.backends.xsendfile' +# https://github.com/moggers87/django-sendfile2 +SENDFILE_BACKEND = 'django_sendfile.backends.xsendfile' # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases diff --git a/tests/cypress/support/commands_projects.js b/tests/cypress/support/commands_projects.js index e0544c383779..e423445d043a 100644 --- a/tests/cypress/support/commands_projects.js +++ b/tests/cypress/support/commands_projects.js @@ -131,8 +131,9 @@ Cypress.Commands.add('restoreProject', (archiveWithBackup) => { Cypress.Commands.add('getDownloadFileName', () => { cy.intercept('GET', '**=download').as('download'); cy.wait('@download').then((download) => { - const filename = download.response.headers['content-disposition'].split('filename="b\'')[1].split('\'')[0]; - return filename; + const filename = download.response.headers['content-disposition'].split(';')[1].split('filename=')[1]; + // need to remove quotes + return filename.substring(1, filename.length - 1); }); });