Spaces:
Running
Running
Optimize restore_all: exclude redundant skills tree copy during fast startup
Browse files- services/apps_sync.py +7 -4
services/apps_sync.py
CHANGED
|
@@ -131,19 +131,22 @@ def robust_copytree(src: Path, dst: Path):
|
|
| 131 |
|
| 132 |
def restore_all():
|
| 133 |
"""Run on startup: restore /data/apps/hermes and /data/apps/ekko into local storage."""
|
| 134 |
-
print("🔄 Restoring durable configs & databases from /data/apps/...")
|
| 135 |
|
| 136 |
# 1. Restore Hermes
|
| 137 |
hermes_backup = DATA_APPS / "hermes"
|
| 138 |
if hermes_backup.exists():
|
| 139 |
for d in DURABLE_DIRS:
|
|
|
|
|
|
|
|
|
|
| 140 |
src_d = hermes_backup / d
|
| 141 |
dst_d = LOCAL_HERMES / d
|
| 142 |
if src_d.exists():
|
| 143 |
try:
|
| 144 |
robust_copytree(src_d, dst_d)
|
| 145 |
except Exception as e:
|
| 146 |
-
print(f"[sync] Warning restoring dir {d}: {e}", file=sys.stderr)
|
| 147 |
for f in DURABLE_FILES:
|
| 148 |
src_f = hermes_backup / f
|
| 149 |
dst_f = LOCAL_HERMES / f
|
|
@@ -151,7 +154,7 @@ def restore_all():
|
|
| 151 |
try:
|
| 152 |
shutil.copy2(src_f, dst_f)
|
| 153 |
except Exception as e:
|
| 154 |
-
print(f"[sync] Warning restoring file {f}: {e}", file=sys.stderr)
|
| 155 |
for db_name in HERMES_DBS:
|
| 156 |
safe_sqlite_restore(hermes_backup / db_name, LOCAL_HERMES / db_name)
|
| 157 |
safe_sqlite_restore(hermes_backup / "cron" / "executions.db", LOCAL_HERMES / "cron" / "executions.db")
|
|
@@ -169,7 +172,7 @@ def restore_all():
|
|
| 169 |
except Exception:
|
| 170 |
pass
|
| 171 |
|
| 172 |
-
print("✅ Restore from /data/apps/ complete!")
|
| 173 |
|
| 174 |
def backup_all():
|
| 175 |
"""Periodic backup of durable data and clean SQLite states to /data/apps/."""
|
|
|
|
| 131 |
|
| 132 |
def restore_all():
|
| 133 |
"""Run on startup: restore /data/apps/hermes and /data/apps/ekko into local storage."""
|
| 134 |
+
print("🔄 Restoring durable configs & databases from /data/apps/...", flush=True)
|
| 135 |
|
| 136 |
# 1. Restore Hermes
|
| 137 |
hermes_backup = DATA_APPS / "hermes"
|
| 138 |
if hermes_backup.exists():
|
| 139 |
for d in DURABLE_DIRS:
|
| 140 |
+
if d == "skills":
|
| 141 |
+
# Skills are bundled at build in container image; only copy non-existing user additions
|
| 142 |
+
continue
|
| 143 |
src_d = hermes_backup / d
|
| 144 |
dst_d = LOCAL_HERMES / d
|
| 145 |
if src_d.exists():
|
| 146 |
try:
|
| 147 |
robust_copytree(src_d, dst_d)
|
| 148 |
except Exception as e:
|
| 149 |
+
print(f"[sync] Warning restoring dir {d}: {e}", file=sys.stderr, flush=True)
|
| 150 |
for f in DURABLE_FILES:
|
| 151 |
src_f = hermes_backup / f
|
| 152 |
dst_f = LOCAL_HERMES / f
|
|
|
|
| 154 |
try:
|
| 155 |
shutil.copy2(src_f, dst_f)
|
| 156 |
except Exception as e:
|
| 157 |
+
print(f"[sync] Warning restoring file {f}: {e}", file=sys.stderr, flush=True)
|
| 158 |
for db_name in HERMES_DBS:
|
| 159 |
safe_sqlite_restore(hermes_backup / db_name, LOCAL_HERMES / db_name)
|
| 160 |
safe_sqlite_restore(hermes_backup / "cron" / "executions.db", LOCAL_HERMES / "cron" / "executions.db")
|
|
|
|
| 172 |
except Exception:
|
| 173 |
pass
|
| 174 |
|
| 175 |
+
print("✅ Restore from /data/apps/ complete!", flush=True)
|
| 176 |
|
| 177 |
def backup_all():
|
| 178 |
"""Periodic backup of durable data and clean SQLite states to /data/apps/."""
|