Spaces:
Running
Running
Update hermes-sync.py
Browse files- hermes-sync.py +16 -1
hermes-sync.py
CHANGED
|
@@ -14,6 +14,7 @@ import tempfile
|
|
| 14 |
import threading
|
| 15 |
import time
|
| 16 |
from pathlib import Path
|
|
|
|
| 17 |
|
| 18 |
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
|
| 19 |
os.environ.setdefault("HF_HUB_VERBOSITY", "error")
|
|
@@ -48,6 +49,13 @@ EXCLUDED_TOP_LEVEL = {"logs", STATE_FILE.name}
|
|
| 48 |
if not INCLUDE_ENV:
|
| 49 |
EXCLUDED_TOP_LEVEL.add(".env")
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
HF_API = HfApi(token=HF_TOKEN) if HF_TOKEN else None
|
| 52 |
STOP_EVENT = threading.Event()
|
| 53 |
_REPO_ID_CACHE: str | None = None
|
|
@@ -117,6 +125,7 @@ def ensure_repo_exists() -> str:
|
|
| 117 |
return repo_id
|
| 118 |
|
| 119 |
|
|
|
|
| 120 |
def should_exclude(rel_posix: str, path: Path) -> bool:
|
| 121 |
parts = Path(rel_posix).parts
|
| 122 |
if not parts:
|
|
@@ -125,6 +134,12 @@ def should_exclude(rel_posix: str, path: Path) -> bool:
|
|
| 125 |
return True
|
| 126 |
if any(part in EXCLUDED_DIRS for part in parts):
|
| 127 |
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
# Exclude SQLite temporary files (shm, wal, journal)
|
| 129 |
if path.is_file():
|
| 130 |
name_lower = path.name.lower()
|
|
@@ -340,4 +355,4 @@ def main() -> int:
|
|
| 340 |
|
| 341 |
|
| 342 |
if __name__ == "__main__":
|
| 343 |
-
raise SystemExit(main())
|
|
|
|
| 14 |
import threading
|
| 15 |
import time
|
| 16 |
from pathlib import Path
|
| 17 |
+
import fnmatch
|
| 18 |
|
| 19 |
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
|
| 20 |
os.environ.setdefault("HF_HUB_VERBOSITY", "error")
|
|
|
|
| 49 |
if not INCLUDE_ENV:
|
| 50 |
EXCLUDED_TOP_LEVEL.add(".env")
|
| 51 |
|
| 52 |
+
# --- NUEVO: Patrones de archivos que contienen potencialmente el token HF ---
|
| 53 |
+
EXCLUDED_CONTENT_PATHS = [
|
| 54 |
+
".local/share/tirith/log.jsonl", # Logs de Tirith
|
| 55 |
+
"memories/MEMORY.md", # Fichero de memoria
|
| 56 |
+
"sessions/*.jsonl", # Archivos de sesión
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
HF_API = HfApi(token=HF_TOKEN) if HF_TOKEN else None
|
| 60 |
STOP_EVENT = threading.Event()
|
| 61 |
_REPO_ID_CACHE: str | None = None
|
|
|
|
| 125 |
return repo_id
|
| 126 |
|
| 127 |
|
| 128 |
+
# --- FUNCIÓN ACTUALIZADA ---
|
| 129 |
def should_exclude(rel_posix: str, path: Path) -> bool:
|
| 130 |
parts = Path(rel_posix).parts
|
| 131 |
if not parts:
|
|
|
|
| 134 |
return True
|
| 135 |
if any(part in EXCLUDED_DIRS for part in parts):
|
| 136 |
return True
|
| 137 |
+
|
| 138 |
+
# --- NUEVO: Excluir archivos que contengan el token HF (según patrones) ---
|
| 139 |
+
for pattern in EXCLUDED_CONTENT_PATHS:
|
| 140 |
+
if fnmatch.fnmatch(rel_posix, pattern):
|
| 141 |
+
return True
|
| 142 |
+
|
| 143 |
# Exclude SQLite temporary files (shm, wal, journal)
|
| 144 |
if path.is_file():
|
| 145 |
name_lower = path.name.lower()
|
|
|
|
| 355 |
|
| 356 |
|
| 357 |
if __name__ == "__main__":
|
| 358 |
+
raise SystemExit(main())
|