fix(desktop): satisfy updater prerequisite lint rules

This commit is contained in:
Teknium
2026-09-07 05:43:13 -07:00
parent f4fa6bf2dc
commit 202128f28f
3 changed files with 13 additions and 4 deletions
+3 -1
View File
@@ -398,10 +398,10 @@ import {
resolvePosixScriptHandoff,
resolveStagedUpdaterBinary,
resolveUpdateScriptHandoff,
windowsUpdatePrerequisiteError,
sandboxFallbackFromEnv,
spawnUpdaterProcess,
stagedUpdaterSupportsPrewrittenMarker,
windowsUpdatePrerequisiteError,
wrapHandoffForDetachedConsole
} from './updater-process'
import {
@@ -4052,8 +4052,10 @@ async function applyUpdates(opts: { stopSafeBlockers?: boolean } = {}) {
if (IS_WINDOWS && resolveUpdateScriptHandoff(updateRoot)) {
const message = windowsUpdatePrerequisiteError(updateRoot)
if (message) {
emitUpdateProgress({ stage: 'error', message, percent: null })
return { ok: false, error: message }
}
}
@@ -1,12 +1,15 @@
import assert from 'node:assert/strict'
import { mkdtempSync, mkdirSync, writeFileSync, unlinkSync, rmSync } from 'node:fs'
import { mkdirSync, mkdtempSync, rmSync, unlinkSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import path from 'node:path'
import { test } from 'vitest'
import { windowsUpdatePrerequisiteError } from './updater-process'
test('handoff prerequisites fail closed without requiring dependencies, shim or browser UI', () => {
const root = mkdtempSync(path.join(tmpdir(), 'hermes-prerequisites-'))
try {
const python = path.join(root, 'venv', 'Scripts', 'python.exe')
const script = path.join(root, 'scripts', 'desktop-update', 'windows.ps1')
+6 -2
View File
@@ -8,12 +8,16 @@ import { hiddenWindowsChildOptions } from './windows-child-options'
export function windowsUpdatePrerequisiteError(updateRoot: string): string | null {
const maintainedDir = path.join(updateRoot, 'scripts', 'desktop-update')
const required = [path.join(updateRoot, 'venv', 'Scripts', 'python.exe')]
// Pre-reorg flat scripts remain supported; damaged modern trees do not.
if (existsSync(maintainedDir)) required.push(path.join(maintainedDir, 'windows.ps1'))
if (existsSync(maintainedDir)) {required.push(path.join(maintainedDir, 'windows.ps1'))}
for (const candidate of required) {
if (stagedFileExists(candidate)) continue
if (stagedFileExists(candidate)) {continue}
return `Update aborted: ${candidate} is missing or unreadable. Repair the installation and review antivirus quarantine before retrying.`
}
return null
}