mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-30 21:38:55 -06:00
fix: hold the repository for source-paths.json
This commit is contained in:
1 parent
bdfdb608e0
commit
30113783c9
4 files changed
+52
-21
No files matched your search
+11
-11
@@ -647,23 +647,23 @@ def _refresh_source_paths(args: argparse.Namespace) -> None:
|
||||
return
|
||||
from model.profiles import emulator_profiles_cache
|
||||
from sitegen import sources
|
||||
from core.artifacts import write_if_changed
|
||||
from core.artifacts import ArtifactLockBusy
|
||||
|
||||
# The run loaded the profiles before writing them, and the loader caches
|
||||
# by directory: read again, the record described the pins just replaced
|
||||
# (linapple, then ten profiles in one advance).
|
||||
emulator_profiles_cache.clear()
|
||||
profiles = load_emulator_profiles(args.emulators_dir, skip_aliases=False)
|
||||
held, unread = sources.build_source_paths(
|
||||
profiles, [sources.TREE_CACHE], fetch=True
|
||||
)
|
||||
held = sources.keep_unread(
|
||||
held, unread, sources.read_record(sources.SOURCE_PATHS)
|
||||
)
|
||||
sources.SOURCE_PATHS.parent.mkdir(parents=True, exist_ok=True)
|
||||
write_if_changed(
|
||||
str(sources.SOURCE_PATHS), json.dumps(held, indent=1, sort_keys=True) + "\n"
|
||||
)
|
||||
try:
|
||||
held, unread = sources.refresh_record(profiles, [sources.TREE_CACHE], fetch=True)
|
||||
except ArtifactLockBusy as exc:
|
||||
# The profiles are written: only the record waits for the other run.
|
||||
print(
|
||||
f"source paths not refreshed ({exc}): run python scripts/sitesources.py "
|
||||
"--fetch once it finishes",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return
|
||||
print(
|
||||
f"source paths: {sum(map(len, held.values()))} in {len(held)} trees, "
|
||||
f"{len(unread)} trees not cached: {sources.SOURCE_PATHS}",
|
||||
|
||||
@@ -12,6 +12,7 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from core import upstream
|
||||
from core.artifacts import repository_output_lock, write_if_changed
|
||||
from core.paths import REPO_ROOT
|
||||
from model.sourceref import (
|
||||
HEX_ADDRESS_RE,
|
||||
@@ -370,6 +371,19 @@ def read_record(path: Path) -> dict[str, list[str]]:
|
||||
return {}
|
||||
|
||||
|
||||
def refresh_record(
|
||||
profiles: dict, cache_dirs: list[Path], fetch: bool, output: Path = SOURCE_PATHS,
|
||||
) -> tuple[dict[str, list[str]], list[str]]:
|
||||
"""Rebuild and write the record of cited source paths, under the
|
||||
repository hold when *output* is one of its outputs (website/)."""
|
||||
with repository_output_lock(str(output)):
|
||||
held, unread = build_source_paths(profiles, cache_dirs, fetch)
|
||||
held = keep_unread(held, unread, read_record(output))
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
write_if_changed(str(output), json.dumps(held, indent=1, sort_keys=True) + "\n")
|
||||
return held, unread
|
||||
|
||||
|
||||
def _commit_url(repo: upstream.Repo, pin: str) -> str:
|
||||
"""Forge-specific browser URL for one commit."""
|
||||
base = f"https://{repo.host}/{repo.owner}/{repo.name}"
|
||||
|
||||
@@ -6,11 +6,10 @@ was written against, so a permalink is pinned, never guessed."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from sitegen.sources import SOURCE_PATHS, TREE_CACHE, build_source_paths, keep_unread, read_record
|
||||
from sitegen.sources import SOURCE_PATHS, TREE_CACHE, refresh_record
|
||||
|
||||
|
||||
def main() -> int:
|
||||
@@ -40,14 +39,9 @@ def main() -> int:
|
||||
print(f"Error: no tree cache at {', '.join(map(str, cache_dirs))}", file=sys.stderr)
|
||||
return 1
|
||||
from model.profiles import load_emulator_profiles
|
||||
from core.artifacts import repository_output_lock, write_if_changed
|
||||
|
||||
profiles = load_emulator_profiles(args.emulators_dir, skip_aliases=False)
|
||||
with repository_output_lock(str(args.output)):
|
||||
held, unread = build_source_paths(profiles, cache_dirs, args.fetch)
|
||||
held = keep_unread(held, unread, read_record(args.output))
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
write_if_changed(str(args.output), json.dumps(held, indent=1, sort_keys=True) + "\n")
|
||||
held, unread = refresh_record(profiles, cache_dirs, args.fetch, args.output)
|
||||
print(f"{sum(map(len, held.values()))} paths held in {len(held)} trees, "
|
||||
f"{len(unread)} trees not cached: {args.output}")
|
||||
return 0
|
||||
|
||||
Reference in new issue
Block a user