~edwargix/git.sr.ht

0797e15451b4ed8014ace7c38d21a3aaec3bb807 — Thorben Günther 2 years ago df41ac8
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
M gitsrht/blueprints/api/porcelain.py => gitsrht/blueprints/api/porcelain.py +1 -1
@@ 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")


M gitsrht/blueprints/artifacts.py => gitsrht/blueprints/artifacts.py +1 -1
@@ 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("/<owner>/<repo>/refs/delete/<path:ref>/<filename>", methods=["POST"])
@loginrequired

M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +3 -3
@@ 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("/<owner>/<repo>/archive/<path:ref>.<any('tar.gz','tar'):fmt>.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):