* Load cache metadata for an MCPB source
( cacheDir: string, source: string, )
| 441 | * Load cache metadata for an MCPB source |
| 442 | */ |
| 443 | async function loadCacheMetadata( |
| 444 | cacheDir: string, |
| 445 | source: string, |
| 446 | ): Promise<McpbCacheMetadata | null> { |
| 447 | const fs = getFsImplementation() |
| 448 | const metadataPath = getMetadataPath(cacheDir, source) |
| 449 | |
| 450 | try { |
| 451 | const content = await fs.readFile(metadataPath, { encoding: 'utf-8' }) |
| 452 | return jsonParse(content) as McpbCacheMetadata |
| 453 | } catch (error) { |
| 454 | const code = getErrnoCode(error) |
| 455 | if (code === 'ENOENT') return null |
| 456 | const errorObj = toError(error) |
| 457 | logError(errorObj) |
| 458 | logForDebugging(`Failed to load MCPB cache metadata: ${error}`, { |
| 459 | level: 'error', |
| 460 | }) |
| 461 | return null |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * Save cache metadata for an MCPB source |
no test coverage detected