mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-04-13 12:22:33 -05:00
refactor: skip writing generated files when content unchanged
write_if_changed in common.py compares content after stripping timestamps (generated_at, Auto-generated on, Generated on). applied to generate_db, generate_readme, generate_site. eliminates timestamp-only diffs in database.json, README.md, mkdocs.yml, and 423 docs pages.
This commit is contained in:
@@ -18,7 +18,7 @@ from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from common import compute_hashes, list_registered_platforms
|
||||
from common import compute_hashes, list_registered_platforms, write_if_changed
|
||||
|
||||
CACHE_DIR = ".cache"
|
||||
CACHE_FILE = os.path.join(CACHE_DIR, "db_cache.json")
|
||||
@@ -315,14 +315,15 @@ def main():
|
||||
"indexes": indexes,
|
||||
}
|
||||
|
||||
with open(args.output, "w") as f:
|
||||
json.dump(database, f, indent=2)
|
||||
new_content = json.dumps(database, indent=2)
|
||||
written = write_if_changed(args.output, new_content)
|
||||
|
||||
save_cache(CACHE_FILE, new_cache)
|
||||
|
||||
alias_count = sum(len(v) for v in aliases.values())
|
||||
name_count = len(indexes["by_name"])
|
||||
print(f"Generated {args.output}: {len(files)} files, {total_size:,} bytes total")
|
||||
status = "Generated" if written else "Unchanged"
|
||||
print(f"{status} {args.output}: {len(files)} files, {total_size:,} bytes total")
|
||||
print(f" Name index: {name_count} names ({alias_count} aliases)")
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user