From a11ba1cb9163ab8f18781f243391b9792b53e19c Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Mon, 22 Jun 2026 19:22:18 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Auto-deploy:=20BrainKP=20atualiz?= =?UTF-8?q?ado=20em=2022/06/2026=2019:22:18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.py b/app.py index 08cd93a..1e18321 100644 --- a/app.py +++ b/app.py @@ -152,8 +152,15 @@ def list_rclone_contents(remote, path="", depth=1): pass return [] +import time +_stats_cache = {"data": None, "timestamp": 0} + def get_backup_stats(): """Get backup stats from GDrive.""" + global _stats_cache + if _stats_cache["data"] and (time.time() - _stats_cache["timestamp"] < 60): + return _stats_cache["data"] + stats = { "apps": {"count": 0, "latest": None, "size": 0}, "bd": {"count": 0, "latest": None, "size": 0}, @@ -204,6 +211,8 @@ def get_backup_stats(): except: pass + _stats_cache["data"] = stats + _stats_cache["timestamp"] = time.time() return stats @app.route("/api/status") @@ -443,6 +452,8 @@ def run_backup(): stderr=subprocess.STDOUT, cwd="/root" ) + global _stats_cache + _stats_cache["timestamp"] = 0 # Invalidate cache return jsonify({"ok": True, "message": f"{script} backup started", "pid": proc.pid}) except Exception as e: return jsonify({"error": str(e), "trace": traceback.format_exc()}), 500