(archiveName, checksumsDir)
| 261 | } |
| 262 | |
| 263 | function getExpectedChecksum(archiveName, checksumsDir) { |
| 264 | const dir = checksumsDir || path.join(__dirname, ".."); |
| 265 | const checksumsPath = path.join(dir, "checksums.txt"); |
| 266 | |
| 267 | if (!fs.existsSync(checksumsPath)) { |
| 268 | console.error( |
| 269 | "[WARN] checksums.txt not found, skipping checksum verification" |
| 270 | ); |
| 271 | return null; |
| 272 | } |
| 273 | |
| 274 | const content = fs.readFileSync(checksumsPath, "utf8"); |
| 275 | for (const line of content.split("\n")) { |
| 276 | const trimmed = line.trim(); |
| 277 | if (!trimmed) continue; |
| 278 | const idx = trimmed.indexOf(" "); |
| 279 | if (idx === -1) continue; |
| 280 | const hash = trimmed.slice(0, idx); |
| 281 | const name = trimmed.slice(idx + 2); |
| 282 | if (name === archiveName) return hash; |
| 283 | } |
| 284 | |
| 285 | throw new Error(`Checksum entry not found for ${archiveName}`); |
| 286 | } |
| 287 | |
| 288 | function verifyChecksum(archivePath, expectedHash) { |
| 289 | if (expectedHash === null) return; |
no outgoing calls
no test coverage detected