mirror of
https://github.com/sct/overseerr.git
synced 2025-12-28 16:56:19 +01:00
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
25 lines
600 B
TypeScript
25 lines
600 B
TypeScript
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;
|
|
settings.main.streamingRegion = oldRegion;
|
|
} else {
|
|
settings.main.discoverRegion = '';
|
|
settings.main.streamingRegion = 'US';
|
|
}
|
|
delete settings.main.region;
|
|
|
|
return settings;
|
|
};
|
|
|
|
export default migrateRegionSetting;
|