Fix backup zip download cleanup
This commit is contained in:
+5
-7
@@ -9,7 +9,6 @@ import sqlite3
|
||||
|
||||
from flask import (
|
||||
Blueprint,
|
||||
after_this_request,
|
||||
current_app,
|
||||
flash,
|
||||
g,
|
||||
@@ -3710,18 +3709,17 @@ def backup_export():
|
||||
current_app.config["APP_VERSION"],
|
||||
)
|
||||
|
||||
@after_this_request
|
||||
def cleanup_backup(response):
|
||||
Path(archive_path).unlink(missing_ok=True)
|
||||
return response
|
||||
|
||||
return send_file(
|
||||
archive_size = Path(archive_path).stat().st_size
|
||||
response = send_file(
|
||||
archive_path,
|
||||
as_attachment=True,
|
||||
download_name=download_name,
|
||||
mimetype="application/zip",
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user