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