From fb87a2377a5611c3e49ac20f54e89784440312e7 Mon Sep 17 00:00:00 2001 From: Thomas Stallinger Date: Tue, 1 Sep 2026 16:04:42 +0200 Subject: [PATCH] iso-builds: Dateigroesse speichern und ausliefern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- app.py | 17 +++++++++++------ migrations/0024_iso_build_size.sql | 5 +++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 migrations/0024_iso_build_size.sql diff --git a/app.py b/app.py index fd86e38..f9fe57c 100644 --- a/app.py +++ b/app.py @@ -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) diff --git a/migrations/0024_iso_build_size.sql b/migrations/0024_iso_build_size.sql new file mode 100644 index 0000000..c88d4b0 --- /dev/null +++ b/migrations/0024_iso_build_size.sql @@ -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;