MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / _disk_save

Method _disk_save

src/pyspector/ast_cache.py:421–444  ·  view source on GitHub ↗
(self, entry: FileCacheEntry)

Source from the content-addressed store, hash-verified

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 ───────────────────────────────────────────────────

Callers 1

_get_entryMethod · 0.95

Calls 2

_disk_pathMethod · 0.95
_serialize_entryFunction · 0.85

Tested by

no test coverage detected