Skip to content

Commit 19943c5

Browse files
fix(desktop): a failed update-track save keeps offering the current track's updates
Restore the previous release floor when persisting the new update channel fails, so later checks on the unchanged track are not filtered by the requested track's minimum version. Fixes #34876 AI-assisted; verified with the tests and tools listed above.
1 parent 202e3e1 commit 19943c5

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

‎apps/desktop/src/updates/DesktopUpdates.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,10 @@ export const make = Effect.gen(function* () {
12291229
}
12301230

12311231
return yield* Effect.gen(function* () {
1232-
yield* Ref.set(releaseFloorRef, Option.fromNullishOr(options?.minimumVersion));
1232+
const previousFloor = yield* Ref.getAndSet(
1233+
releaseFloorRef,
1234+
Option.fromNullishOr(options?.minimumVersion),
1235+
);
12331236
const state = yield* Ref.get(updateStateRef);
12341237
const retained = state.downloadedVersion ?? state.availableVersion;
12351238
// A build from another track re-checks, so retrying a track switch finds an older release.
@@ -1242,13 +1245,12 @@ export const make = Effect.gen(function* () {
12421245
return state;
12431246
}
12441247

1245-
yield* desktopSettings
1246-
.setUpdateChannel(nextChannel)
1247-
.pipe(
1248-
Effect.mapError(
1249-
(cause) => new DesktopUpdateChannelPersistenceError({ channel: nextChannel, cause }),
1250-
),
1251-
);
1248+
yield* desktopSettings.setUpdateChannel(nextChannel).pipe(
1249+
Effect.onError(() => Ref.set(releaseFloorRef, previousFloor)),
1250+
Effect.mapError(
1251+
(cause) => new DesktopUpdateChannelPersistenceError({ channel: nextChannel, cause }),
1252+
),
1253+
);
12521254

12531255
const disabledReason = yield* resolveDisabledReason;
12541256
yield* setState(yield* baseUpdateState(nextChannel, disabledReason));

0 commit comments

Comments
 (0)