From 0797e15451b4ed8014ace7c38d21a3aaec3bb807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Mon, 26 Sep 2022 13:29:24 +0200 Subject: [PATCH] Fix flask send_file arguments The deprecated attachment_filename was removed in a recent flask release and is superseded by download_name [1]. [1]: https://github.com/pallets/flask/pull/4667 --- gitsrht/blueprints/api/porcelain.py | 2 +- gitsrht/blueprints/artifacts.py | 2 +- gitsrht/blueprints/repo.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gitsrht/blueprints/api/porcelain.py b/gitsrht/blueprints/api/porcelain.py index be9a987..65f0626 100644 --- a/gitsrht/blueprints/api/porcelain.py +++ b/gitsrht/blueprints/api/porcelain.py @@ -253,7 +253,7 @@ def repo_blob_GET(username, reponame, ref, path): return send_file(BytesIO(blob.data), as_attachment=blob.is_binary, - attachment_filename=attachment_filename, + download_name=attachment_filename, mimetype="text/plain" if not blob.is_binary else "application/x-octet-stream") diff --git a/gitsrht/blueprints/artifacts.py b/gitsrht/blueprints/artifacts.py index 1c42cbe..5ec1191 100644 --- a/gitsrht/blueprints/artifacts.py +++ b/gitsrht/blueprints/artifacts.py @@ -85,7 +85,7 @@ def ref_download(owner, repo, ref, filename): minio = Minio(s3_upstream, access_key=s3_access_key, secret_key=s3_secret_key, secure=True) f = minio.get_object(s3_bucket, os.path.join(prefix, filename)) - return send_file(f, as_attachment=True, attachment_filename=filename) + return send_file(f, as_attachment=True, download_name=filename) @artifacts.route("///refs/delete//", methods=["POST"]) @loginrequired diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index f665e4d..fdcd9d9 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -322,7 +322,7 @@ def raw_blob(owner, repo, ref, path): return send_file(BytesIO(blob.data), as_attachment=blob.is_binary, - attachment_filename=entry.name, + download_name=entry.name, mimetype="text/plain" if not blob.is_binary else None) def _lookup_user(email, cache): @@ -410,7 +410,7 @@ def archive(owner, repo, ref): subp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=sys.stderr) return send_file(subp.stdout, mimetype="application/tar+gzip", - as_attachment=True, attachment_filename=f"{repo.name}-{refname}.tar.gz") + as_attachment=True, download_name=f"{repo.name}-{refname}.tar.gz") @repo.route("///archive/..asc") def archivesig(owner, repo, ref, fmt): @@ -421,7 +421,7 @@ def archivesig(owner, repo, ref, fmt): abort(404) return send_file(BytesIO(sigdata.encode('utf-8')), mimetype="application/pgp-signature", - as_attachment=True, attachment_filename=f"{repo.name}-{ref}.{fmt}.asc") + as_attachment=True, download_name=f"{repo.name}-{ref}.{fmt}.asc") class _AnnotatedRef: def __init__(self, repo, ref): -- 2.38.4