( sessionId: string, )
| 939 | } |
| 940 | |
| 941 | async function loadCachedFacets( |
| 942 | sessionId: string, |
| 943 | ): Promise<SessionFacets | null> { |
| 944 | const facetPath = join(getFacetsDir(), `${sessionId}.json`) |
| 945 | try { |
| 946 | const content = await readFile(facetPath, { encoding: 'utf-8' }) |
| 947 | const parsed: unknown = jsonParse(content) |
| 948 | if (!isValidSessionFacets(parsed)) { |
| 949 | // Delete corrupted cache file so it gets re-extracted next run |
| 950 | try { |
| 951 | await unlink(facetPath) |
| 952 | } catch { |
| 953 | // Ignore deletion errors |
| 954 | } |
| 955 | return null |
| 956 | } |
| 957 | return parsed |
| 958 | } catch { |
| 959 | return null |
| 960 | } |
| 961 | } |
| 962 | |
| 963 | async function saveFacets(facets: SessionFacets): Promise<void> { |
| 964 | try { |
no test coverage detected