From 78f5118e1ea154eed4471c31bfbaccaadcfab810 Mon Sep 17 00:00:00 2001 From: Denys SAVCHENKO Date: Wed, 8 Jan 2025 14:42:59 +0100 Subject: [PATCH 1/2] gzip-compressed mimetype if download one compressed file --- cdci_data_analysis/flask_app/dispatcher_query.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cdci_data_analysis/flask_app/dispatcher_query.py b/cdci_data_analysis/flask_app/dispatcher_query.py index fac51539..41906c36 100644 --- a/cdci_data_analysis/flask_app/dispatcher_query.py +++ b/cdci_data_analysis/flask_app/dispatcher_query.py @@ -1168,6 +1168,9 @@ def download_file(self, from_request_files_dir=False): if file_name is None: file_name = file_list[0] if len(file_list) == 1 else 'download.tar.gz' return_archive = self.args.get('return_archive', 'True') == 'True' + mimetype = 'application/x-gzip-compressed' if return_archive and len(file_list) == 1 else None + # otherwise, for one file, the mimetype of the uncompressed file is determined, and gz only affects Content-Encoding + # but Content-Encoding header isn't set if as_attachment=True tmp_dir, target_file = self.prepare_download( file_list, file_name, @@ -1175,10 +1178,10 @@ def download_file(self, from_request_files_dir=False): from_request_files_dir=from_request_files_dir) try: return send_from_directory(directory=tmp_dir, path=target_file, attachment_filename=target_file, - as_attachment=True) + as_attachment=True, mimetype=mimetype) except Exception as e: return send_from_directory(directory=tmp_dir, filename=target_file, attachment_filename=target_file, - as_attachment=True) + as_attachment=True, mimetype=mimetype) except RequestNotAuthorized as e: extract_job_monitor = True if not hasattr(self, 'scratch_dir') or self.scratch_dir is None: From 8f443259d2a0ea2c35bdbed3870f286a313a91f7 Mon Sep 17 00:00:00 2001 From: Denys SAVCHENKO Date: Wed, 8 Jan 2025 15:23:59 +0100 Subject: [PATCH 2/2] restrict marshmallow --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a28f3183..5d5c279a 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ "celery", "redis", "pyjwt", - "marshmallow", + "marshmallow<3.24", "black>=22.10.0", "bs4", "GitPython",