mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-04 17:38:45 +00:00
Treat Git paths literally so unusual filenames cannot expand into excluded files. Reject restores that would change excluded paths, nested Git workspaces, or files through directory symlinks. Serialize complete workspace operations with reentrant cross-process locks shared by retention. Skip busy or symlinked histories, fail closed when owners cannot be enumerated, and count only successful cleanup. Verified with 38 focused tests, including cross-process cleanup, concurrent snapshots, exclusion bypasses, and restore safety. Keep test shadow repositories isolated from user history.
12 lines
386 B
Python
12 lines
386 B
Python
"""Locks shared by history operations and retention, outside removable repositories."""
|
|
|
|
from pathlib import Path
|
|
|
|
from filelock import FileLock
|
|
|
|
|
|
def workspace_lock(shadow_path: Path) -> FileLock:
|
|
lock_dir = shadow_path.parent / ".locks"
|
|
lock_dir.mkdir(parents=True, exist_ok=True)
|
|
return FileLock(str(lock_dir / f"{shadow_path.name}.lock"), timeout=20, is_singleton=True)
|