mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 17:33:30 -05:00
fix: hold data directories while packs read them
This commit is contained in:
1 parent
d98f00cfbc
commit
1ffc0a6937
5 files changed
+101
-3
No files matched your search
@@ -62,6 +62,21 @@ def cache_lock(cache_dir: str | Path, shared: bool = False):
|
||||
return _file_lock(cache_dir.with_name(f".{cache_dir.name}.lock"), shared=shared)
|
||||
|
||||
|
||||
def hold_data_dirs(stack: contextlib.ExitStack, registry: dict) -> None:
|
||||
"""Hold every cached data directory shared for the life of *stack*.
|
||||
|
||||
A pack resolves names against a tree, then copies the file minutes
|
||||
later; a refresh swapping the tree in between shipped bytes nobody
|
||||
verified, or died on a file the new tree no longer has. A refresh waits
|
||||
for the holders. Never called before a refresh in the same process:
|
||||
the exclusive lock would wait on this one.
|
||||
"""
|
||||
for entry in registry.values():
|
||||
cache = entry.get("local_cache", "")
|
||||
if cache and os.path.isdir(cache):
|
||||
stack.enter_context(cache_lock(cache, shared=True))
|
||||
|
||||
|
||||
def _load_versions(versions_path: str = VERSIONS_FILE) -> dict[str, dict]:
|
||||
path = Path(versions_path)
|
||||
if not path.exists():
|
||||
|
||||
Reference in new issue
Block a user