🚀 Auto-deploy: BrainKP atualizado em 22/06/2026 19:22:18
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user