Compare commits

...
Author SHA1 Message Date
Hona 5f4cd892de fix(desktop): prevent update downgrades 2026-08-30 17:01:28 +00:00
3 changed files with 31 additions and 3 deletions

No files matched your search

@@ -0,0 +1,18 @@
import { expect, test } from "bun:test"
import { configureStableUpdates } from "./config"
test("stable updates do not install older releases", () => {
const client = {
channel: null,
allowPrerelease: null,
allowDowngrade: true,
}
configureStableUpdates(client)
expect(client).toEqual({
channel: "latest",
allowPrerelease: false,
allowDowngrade: false,
})
})
@@ -0,0 +1,11 @@
type UpdateClient = {
channel: string | null
allowPrerelease: boolean | null
allowDowngrade: boolean
}
export function configureStableUpdates(client: UpdateClient) {
client.channel = "latest"
client.allowPrerelease = false
client.allowDowngrade = false
}
@@ -2,6 +2,7 @@ import { app, autoUpdater } from "electron"
import pkg from "electron-updater"
import { Effect } from "effect"
import { setAppQuitting } from "../windows"
import { configureStableUpdates } from "./config"
import type { Platform } from "./index"
const updateClient = pkg.autoUpdater
@@ -15,9 +16,7 @@ export const make = Effect.gen(function* () {
error: (...args) => runFork(Effect.logError(...args)),
debug: (...args) => runFork(Effect.logDebug(...args)),
}
updateClient.channel = "latest"
updateClient.allowPrerelease = false
updateClient.allowDowngrade = true
configureStableUpdates(updateClient)
updateClient.autoDownload = false
updateClient.autoInstallOnAppQuit = process.platform === "darwin"
yield* Effect.logInfo("auto updater configured", {