mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 21:43:23 -05:00
fix: keep the cache usable when a path is both
This commit is contained in:
1 parent
1ac569b98e
commit
5330ed1950
5 files changed
+33
-13
No files matched your search
+11
-2
@@ -213,8 +213,17 @@ def cache_path(cache_dir: str, repo: Repo, sha: str, path: str) -> Path:
|
||||
|
||||
|
||||
def write_cache(target: Path, text: str) -> None:
|
||||
"""Atomic write: unique scratch in the target directory, then replace."""
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
"""Atomic write: unique scratch in the target directory, then replace.
|
||||
|
||||
A profile can cite both a directory and files inside it, and the first
|
||||
citation caches `vice/data/C64DTV` as a file, which then blocks the
|
||||
directory the second one needs. The cache is derived data, so a collision
|
||||
skips the write rather than failing the read.
|
||||
"""
|
||||
try:
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
except (FileExistsError, NotADirectoryError):
|
||||
return
|
||||
fd, scratch = tempfile.mkstemp(dir=str(target.parent), suffix=".part")
|
||||
try:
|
||||
with os.fdopen(fd, "w", encoding="utf-8") as fh:
|
||||
|
||||
Reference in new issue
Block a user