fix(update): never offer a lower or equal version on prerelease channels
Setting a channel makes electron-updater allow downgrades, and the channel check let prerelease channels accept them, so a stable install on beta would be asked to 'update' down to an older beta.
This commit is contained in:
parent
4e75f515e2
commit
a03cda2211
2 changed files with 10 additions and 7 deletions
|
|
@ -144,14 +144,10 @@ export function isChannelAcceptable(
|
|||
const targetIsPrerelease = target.prerelease.length > 0
|
||||
// stable 채널은 더 높은 prerelease로 올라가지 않는다.
|
||||
if (!allowPrerelease && targetIsPrerelease && !currentIsPrerelease) return false
|
||||
// prerelease가 아닌 현재 버전보다 낮은/같은 버전으로 내려가지 않는다.
|
||||
// 어느 채널이든 낮은/같은 버전으로 내려가지 않는다. 채널을 지정하면 electron-updater 가 allowDowngrade 를
|
||||
// 켜서 낮은 버전도 update-available 로 보낸다 — 여기서 막지 않으면 정식판에서 beta 로 내려가자고 물었다.
|
||||
const ordering = compareVersions(currentVersion, targetVersion)
|
||||
if (ordering === null) return false
|
||||
if (ordering >= 0) {
|
||||
// 다운그레이드는 채널이 prerelease를 허용할 때만 (예: beta → stable 정렬).
|
||||
return allowPrerelease ? ordering >= 0 : false
|
||||
}
|
||||
return true
|
||||
return ordering !== null && ordering < 0
|
||||
}
|
||||
|
||||
/** 현재 버전·대상 버전·정책으로 업데이트 결정을 계산한다. */
|
||||
|
|
|
|||
|
|
@ -100,6 +100,13 @@ describe('isChannelAcceptable', () => {
|
|||
it('더 높은 버전이 아니면 거부한다', () => {
|
||||
expect(isChannelAcceptable(false, '1.2.0', '1.1.0')).toBe(false)
|
||||
})
|
||||
|
||||
it('beta 채널이어도 낮은/같은 버전으로 내려가지 않는다', () => {
|
||||
expect(isChannelAcceptable(true, '1.3.0', '1.3.0-beta.5')).toBe(false)
|
||||
expect(isChannelAcceptable(true, '1.3.0-beta.6', '1.3.0-beta.5')).toBe(false)
|
||||
expect(isChannelAcceptable(true, '1.3.0-beta.5', '1.3.0-beta.5')).toBe(false)
|
||||
expect(isChannelAcceptable(true, '1.3.0-beta.5', '1.3.0')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('staged rollout', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue