Fix backup zip download cleanup

This commit is contained in:
2026-04-26 12:57:21 +02:00
parent 43fdd7081c
commit d3c58c5dd2
+5 -7
View File
@@ -9,7 +9,6 @@ import sqlite3
from flask import ( from flask import (
Blueprint, Blueprint,
after_this_request,
current_app, current_app,
flash, flash,
g, g,
@@ -3710,18 +3709,17 @@ def backup_export():
current_app.config["APP_VERSION"], current_app.config["APP_VERSION"],
) )
@after_this_request archive_size = Path(archive_path).stat().st_size
def cleanup_backup(response): response = send_file(
Path(archive_path).unlink(missing_ok=True)
return response
return send_file(
archive_path, archive_path,
as_attachment=True, as_attachment=True,
download_name=download_name, download_name=download_name,
mimetype="application/zip", mimetype="application/zip",
max_age=0, max_age=0,
) )
response.content_length = archive_size
response.call_on_close(lambda: Path(archive_path).unlink(missing_ok=True))
return response
@main_bp.post("/settings/backup/restore") @main_bp.post("/settings/backup/restore")