Fix backup zip download cleanup
This commit is contained in:
+5
-7
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user