mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 08:03:28 +00:00
* fix(orchestration): preserve active workers across updates * test(ssh): model absent legacy adoption * test(orchestration): align compatibility contracts * fix(windows): escape updater PowerShell booleans * fix(windows): restore stock uninstall process check * fix(orchestration): keep recovery off renderer startup barrier * fix(orchestration): harden legacy recovery migration * fix(orchestration): close recovery review gaps * fix(orchestration): complete legacy worker cutover recovery * fix(orchestration): preserve legacy workers across updates --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import { createHash } from 'node:crypto'
|
|
import { createReadStream } from 'node:fs'
|
|
import path from 'node:path'
|
|
|
|
async function sha256(filePath) {
|
|
const hash = createHash('sha256')
|
|
for await (const chunk of createReadStream(filePath)) {
|
|
hash.update(chunk)
|
|
}
|
|
return hash.digest('hex')
|
|
}
|
|
|
|
export async function proveDistinctInstallerPair({ fromPath, toPath, fromVersion, toVersion }) {
|
|
const [fromHash, toHash] = await Promise.all([sha256(fromPath), sha256(toPath)])
|
|
const proof = {
|
|
from: { path: path.resolve(fromPath), version: fromVersion, sha256: fromHash },
|
|
to: { path: path.resolve(toPath), version: toVersion, sha256: toHash }
|
|
}
|
|
const errors = []
|
|
if (proof.from.path.toLowerCase() === proof.to.path.toLowerCase()) {
|
|
errors.push('base and candidate installer paths are identical')
|
|
}
|
|
if (fromHash === toHash) {
|
|
errors.push('base and candidate installer SHA-256 hashes are identical')
|
|
}
|
|
if (!fromVersion || !toVersion) {
|
|
errors.push('both installer versions must be readable')
|
|
} else if (fromVersion === toVersion) {
|
|
errors.push(`base and candidate installer versions are identical (${fromVersion})`)
|
|
}
|
|
if (errors.length > 0) {
|
|
throw new Error(`Distinct installer proof failed: ${errors.join('; ')}`)
|
|
}
|
|
return proof
|
|
}
|