iso-builds: Dateigroesse speichern und ausliefern

Neue Spalte size_bytes (Migration 0024, analog zu sha256/Migration 0023) -
wird direkt nach erfolgreichem Bau einmalig berechnet (output_path.stat().
st_size) und zusammen mit sha256 gespeichert, kein Neuberechnen bei jedem
Seitenaufruf noetig.

Nutzer-Feedback (01.09.2026, echter Hardware-Test): "Bitte nach ISO-Build
auch die Größe anzeigen lassen" - kundenplattform zeigt sie jetzt auf
/installationsmedium an (iso_build.size_bytes | filesizeformat).
This commit is contained in:
Thomas Stallinger 2026-09-01 16:04:42 +02:00
parent 0acb1b6b81
commit fb87a2377a
2 changed files with 16 additions and 6 deletions

17
app.py
View File

@ -2147,7 +2147,7 @@ def recharge_enrollment_session(session_id: str, additional_devices: int, expire
def iso_build_row_to_dict(row) -> dict:
(build_id, organization_id, status, output_filename, error_message,
created_at, started_at, finished_at, expires_at, sha256) = row
created_at, started_at, finished_at, expires_at, sha256, size_bytes) = row
return {
"id": str(build_id),
"organization_id": str(organization_id),
@ -2159,6 +2159,7 @@ def iso_build_row_to_dict(row) -> dict:
"finished_at": finished_at.isoformat() if finished_at else None,
"expires_at": expires_at.isoformat() if expires_at else None,
"sha256": sha256,
"size_bytes": size_bytes,
}
def fetch_iso_build(build_id: str):
@ -2167,7 +2168,7 @@ def fetch_iso_build(build_id: str):
cur.execute(
"""
SELECT id, organization_id, status, output_filename, error_message,
created_at, started_at, finished_at, expires_at, sha256
created_at, started_at, finished_at, expires_at, sha256, size_bytes
FROM iso_builds
WHERE id = %s
""",
@ -2182,7 +2183,7 @@ def fetch_iso_builds(organization_id: str):
cur.execute(
"""
SELECT id, organization_id, status, output_filename, error_message,
created_at, started_at, finished_at, expires_at, sha256
created_at, started_at, finished_at, expires_at, sha256, size_bytes
FROM iso_builds
WHERE organization_id = %s
ORDER BY created_at DESC
@ -2209,6 +2210,7 @@ def update_iso_build(
output_filename: str | None = None,
error_message: str | None = None,
sha256: str | None = None,
size_bytes: int | None = None,
mark_started: bool = False,
mark_finished: bool = False,
):
@ -2226,13 +2228,14 @@ def update_iso_build(
SET status = %s,
output_filename = COALESCE(%s, output_filename),
error_message = %s,
sha256 = COALESCE(%s, sha256)
sha256 = COALESCE(%s, sha256),
size_bytes = COALESCE(%s, size_bytes)
{", started_at = CURRENT_TIMESTAMP" if mark_started else ""}
{", finished_at = CURRENT_TIMESTAMP" if mark_finished else ""}
{f", expires_at = CURRENT_TIMESTAMP + INTERVAL '{ISO_BUILD_EXPIRY_DAYS} days'" if setzt_expiry else ""}
WHERE id = %s
""",
(status, output_filename, error_message, sha256, build_id),
(status, output_filename, error_message, sha256, size_bytes, build_id),
)
def cleanup_old_iso_builds(organization_id: str, keep_build_id) -> None:
@ -2395,9 +2398,11 @@ def run_iso_build(build_id, organization_id: str, activation_code: str, wifi_ssi
return
sha256 = compute_file_sha256(output_path)
size_bytes = output_path.stat().st_size
update_iso_build(
build_id, status="completed", output_filename=output_path.name, sha256=sha256, mark_finished=True
build_id, status="completed", output_filename=output_path.name, sha256=sha256,
size_bytes=size_bytes, mark_finished=True
)
cleanup_old_iso_builds(organization_id, build_id)

View File

@ -0,0 +1,5 @@
-- ISO-Groesse fuer die Kundenplattform-Anzeige (01.09.2026, Nutzer-Feedback
-- nach dem ersten echten Hardware-Test: "Bitte nach ISO-Build auch die
-- Groesse anzeigen lassen"). Analog zu sha256 (Migration 0023) einmalig
-- direkt nach erfolgreichem Bau berechnet, nicht bei jedem Seitenaufruf.
ALTER TABLE iso_builds ADD COLUMN size_bytes BIGINT;