🚀 Auto-deploy: BrainKP atualizado em 22/06/2026 19:22:18

This commit is contained in:
2026-06-22 19:22:18 +00:00
parent 96a1e0b66b
commit a11ba1cb91
+11
View File
@@ -152,8 +152,15 @@ def list_rclone_contents(remote, path="", depth=1):
pass pass
return [] return []
import time
_stats_cache = {"data": None, "timestamp": 0}
def get_backup_stats(): def get_backup_stats():
"""Get backup stats from GDrive.""" """Get backup stats from GDrive."""
global _stats_cache
if _stats_cache["data"] and (time.time() - _stats_cache["timestamp"] < 60):
return _stats_cache["data"]
stats = { stats = {
"apps": {"count": 0, "latest": None, "size": 0}, "apps": {"count": 0, "latest": None, "size": 0},
"bd": {"count": 0, "latest": None, "size": 0}, "bd": {"count": 0, "latest": None, "size": 0},
@@ -204,6 +211,8 @@ def get_backup_stats():
except: except:
pass pass
_stats_cache["data"] = stats
_stats_cache["timestamp"] = time.time()
return stats return stats
@app.route("/api/status") @app.route("/api/status")
@@ -443,6 +452,8 @@ def run_backup():
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
cwd="/root" cwd="/root"
) )
global _stats_cache
_stats_cache["timestamp"] = 0 # Invalidate cache
return jsonify({"ok": True, "message": f"{script} backup started", "pid": proc.pid}) return jsonify({"ok": True, "message": f"{script} backup started", "pid": proc.pid})
except Exception as e: except Exception as e:
return jsonify({"error": str(e), "trace": traceback.format_exc()}), 500 return jsonify({"error": str(e), "trace": traceback.format_exc()}), 500