From d899672a2baffeb0bd6c31670c4985c8634807e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Tue, 22 Jul 2025 22:21:10 +0200 Subject: [PATCH] przeliczenie wielkosci plikow --- app.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index e17c059..ee97ac9 100644 --- a/app.py +++ b/app.py @@ -2033,18 +2033,26 @@ def crop_receipt(): def recalculate_filesizes(): updated = 0 not_found = 0 + unchanged = 0 receipts = Receipt.query.all() for r in receipts: filepath = os.path.join(app.config["UPLOAD_FOLDER"], r.filename) if os.path.exists(filepath): - r.filesize = os.path.getsize(filepath) - updated += 1 + real_size = os.path.getsize(filepath) + if r.filesize != real_size: + r.filesize = real_size + updated += 1 + else: + unchanged += 1 else: not_found += 1 db.session.commit() - flash(f"Zaktualizowano rozmiar dla {updated} plików. Nie znaleziono: {not_found}.", "success") + flash( + f"Zaktualizowano: {updated}, bez zmian: {unchanged}, brak pliku: {not_found}", + "success", + ) return redirect(url_for("admin_receipts", id="all"))