fix(settingsmigrator): prevent region migration from running multiple times (#1255)

Adds a guard clause to skip region migration if discoverRegion and
streamingRegion properties already exist in settings. This prevents
accidental overwrites of existing region settings during multiple runs
and ensures the migration only executes when needed.

Previously, the migration would run every time regardless of whether the
new region properties existed, potentially overwriting user preferences.

fix #1251
This commit is contained in:
Fallenbagel
2025-01-14 19:01:42 +08:00
committed by GitHub
parent 4f6192476b
commit 1c6f5362d7

View File

@@ -1,6 +1,13 @@
import type { AllSettings } from '@server/lib/settings';
const migrateRegionSetting = (settings: any): AllSettings => {
if (
settings.main.discoverRegion !== undefined &&
settings.main.streamingRegion !== undefined
) {
return settings;
}
const oldRegion = settings.main.region;
if (oldRegion) {
settings.main.discoverRegion = oldRegion;