Skip to content

The agent that grows with you

fix(desktop): satisfy updater prerequisite lint rules

Teknium202128f28f69
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index d19a36b2e47..d13ea8b7369 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -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 }
}
}
diff --git a/apps/desktop/electron/update-prerequisites.test.ts b/apps/desktop/electron/update-prerequisites.test.ts
index 791b1530cce..4e63b3e7ec7 100644
--- a/apps/desktop/electron/update-prerequisites.test.ts
+++ b/apps/desktop/electron/update-prerequisites.test.ts
@@ -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')
diff --git a/apps/desktop/electron/updater-process.ts b/apps/desktop/electron/updater-process.ts
index 20db836d2d6..86ff2ab6531 100644
--- a/apps/desktop/electron/updater-process.ts
+++ b/apps/desktop/electron/updater-process.ts
@@ -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
}