mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-01 05:40:50 -07:00
fix(electron): allow patch downgrades in the runtime guard
- Compare only major and minor versions, so same-minor patch downgrades are allowed - Keep blocking Electron minor and major downgrades before Yomitan storage loads - Add tests for patch downgrades, minor downgrades and Electron 42 reopening a 43 profile - Document the new rules and the SubMiner-dev profile workaround in troubleshooting
This commit is contained in:
@@ -39,11 +39,11 @@ function parseElectronVersion(version: string): ParsedElectronVersion | null {
|
||||
return { major, minor, patch };
|
||||
}
|
||||
|
||||
function compareElectronVersions(
|
||||
function compareElectronMajorMinorVersions(
|
||||
left: ParsedElectronVersion,
|
||||
right: ParsedElectronVersion,
|
||||
): number {
|
||||
return left.major - right.major || left.minor - right.minor || left.patch - right.patch;
|
||||
return left.major - right.major || left.minor - right.minor;
|
||||
}
|
||||
|
||||
function readRuntimeState(statePath: string): ValidatedElectronRuntimeState | null {
|
||||
@@ -129,7 +129,7 @@ export function enforceElectronRuntimeGuard(options: {
|
||||
if (
|
||||
previousState &&
|
||||
(currentVersion.major < previousState.state.highestElectronMajor ||
|
||||
compareElectronVersions(currentVersion, previousState.version) < 0)
|
||||
compareElectronMajorMinorVersions(currentVersion, previousState.version) < 0)
|
||||
) {
|
||||
return {
|
||||
ok: false,
|
||||
@@ -139,7 +139,7 @@ export function enforceElectronRuntimeGuard(options: {
|
||||
`The current runtime is Electron ${options.electronVersion}.`,
|
||||
`Runtime safety record: ${statePath}.`,
|
||||
'',
|
||||
'Opening Chromium storage with an older Electron version can destroy Yomitan dictionaries. Upgrade SubMiner before using this profile.',
|
||||
'Opening Chromium storage with an older Electron major or minor version can destroy Yomitan dictionaries. Upgrade SubMiner before using this profile. Patch downgrades within the same major and minor version are allowed.',
|
||||
].join('\n'),
|
||||
statePath,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user