fix(desktop): satisfy updater prerequisite lint rules
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user