(self, entry: FileCacheEntry)
| 419 | return None |
| 420 | |
| 421 | def _disk_save(self, entry: FileCacheEntry) -> None: |
| 422 | p = self._disk_path(Path(entry.file_path)) |
| 423 | if not p: |
| 424 | return |
| 425 | tmp = p.with_suffix(".tmp") |
| 426 | try: |
| 427 | tmp.write_text(_serialize_entry(entry), encoding="utf-8") |
| 428 | tmp.replace(p) # atomic on POSIX; best-effort on Windows |
| 429 | except OSError as e: |
| 430 | warnings.warn( |
| 431 | f"PySpector: cache write failed for {entry.file_path!r}: {e}", |
| 432 | stacklevel=2, |
| 433 | ) |
| 434 | except Exception as e: |
| 435 | warnings.warn( |
| 436 | f"PySpector: unexpected cache error for {entry.file_path!r}: {e}", |
| 437 | stacklevel=2, |
| 438 | ) |
| 439 | finally: |
| 440 | # Remove temp file if replace() did not atomically rename it. |
| 441 | try: |
| 442 | tmp.unlink(missing_ok=True) |
| 443 | except OSError: |
| 444 | pass |
| 445 | |
| 446 | |
| 447 | # ── Process-level singleton ─────────────────────────────────────────────────── |
no test coverage detected