(archivePath, archiveName, source)
| 688 | |
| 689 | // Fetch checksums.txt from the same download base and verify the archive hash. |
| 690 | async function verifyChecksum(archivePath, archiveName, source) { |
| 691 | const url = `${source.base}/checksums.txt`; |
| 692 | const tmpChecksums = archivePath + '.checksums'; |
| 693 | try { |
| 694 | await download(url, tmpChecksums, source.loopback); |
| 695 | const expected = parseExpectedChecksum( |
| 696 | fs.readFileSync(tmpChecksums, 'utf-8'), archiveName, |
| 697 | ); |
| 698 | const actual = fileSha256(archivePath); |
| 699 | if (expected !== actual) { |
| 700 | throw new Error( |
| 701 | `Checksum mismatch for ${archiveName}:\n expected: ${expected}\n actual: ${actual}`, |
| 702 | ); |
| 703 | } |
| 704 | process.stdout.write('codebase-memory-mcp: checksum verified.\n'); |
| 705 | } finally { |
| 706 | try { fs.unlinkSync(tmpChecksums); } catch (_) { /* ignore */ } |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | async function main() { |
| 711 | const platform = getPlatform(); |
no test coverage detected