← Commit history

0.9.340: land the shipped runtime source for handlers/install_footprint.py (tour fixes 0.9.318-0.9.339 never reached master, issue #79)

John Lauer ·a7aebbf5fa ·1mo ago ·parent 95750bc
1 file changed +13−1
handlers/install_footprint.py+13−1
@@ -179,7 +179,17 @@ def handle_install_footprint(kicad_info: dict, args: dict) -> dict:      # The .kicad_mod file must be named to match the footprint name inside it     dest_file = pretty_dir / f"{footprint_name}.kicad_mod"-    dest_file.write_text(footprint_text, encoding="utf-8")+    existed_before = dest_file.exists()      # a NEW footprint needs a KiCad restart to be seen (process-wide cache, #47)+    # Identical content: leave the file alone. Rewriting it bumps the mtime past+    # KiCad's cache load and the opener then reports "cache predates the install"+    # on every tour after the first (arav-rog 2026-09-05, footprint beat failed).+    unchanged = False+    try:+        unchanged = existed_before and dest_file.read_text(encoding="utf-8") == footprint_text+    except Exception:  # pylint: disable=broad-except+        unchanged = False+    if not unchanged:+        dest_file.write_text(footprint_text, encoding="utf-8")      # --- Step 3: Register in fp-lib-table --- @@ -246,6 +256,8 @@ def handle_install_footprint(kicad_info: dict, args: dict) -> dict:         "success": True,         "output": " | ".join(output_parts),         "installedPath": str(dest_file),+        "existedBefore": existed_before,+        "unchanged": unchanged,         "footprintName": footprint_name,         "libraryName": ADOM_FP_LIB_NAME,         "editorOpened": editor_opened,