fix(seerr): add main.mediaServerType to settings.json to prevent crash
Seerr's checkOverseerrMerge calls Settings.load with raw=true, which replaces this.data entirely with file contents. If settings.main is absent (as in our jellyfin-only restore), it crashes at line 418: 'Cannot read properties of undefined (reading apiKey)'. restore.js now ensures settings.main exists and mediaServerType=JELLYFIN, which both prevents the crash and causes checkOverseerrMerge to return early (migration already done).
This commit is contained in:
@@ -29,14 +29,26 @@ data:
|
|||||||
if (fs.existsSync(SETTINGS)) {
|
if (fs.existsSync(SETTINGS)) {
|
||||||
try { settings = JSON.parse(fs.readFileSync(SETTINGS, 'utf8')); } catch(e) {}
|
try { settings = JSON.parse(fs.readFileSync(SETTINGS, 'utf8')); } catch(e) {}
|
||||||
}
|
}
|
||||||
|
// Seerr's Settings.load runs in raw mode during the overseerrMerge check,
|
||||||
|
// which replaces this.data entirely with the file contents. If settings.main
|
||||||
|
// is absent, it crashes at "this.data.main.apiKey" (settings/index.js:418).
|
||||||
|
// Ensure main exists with mediaServerType=JELLYFIN so the merge check is skipped.
|
||||||
|
if (!settings.main) {
|
||||||
|
settings.main = {};
|
||||||
|
}
|
||||||
|
if (!settings.main.mediaServerType) {
|
||||||
|
settings.main.mediaServerType = 'JELLYFIN';
|
||||||
|
console.log('Set main.mediaServerType = JELLYFIN');
|
||||||
|
}
|
||||||
if (!settings.jellyfin || !settings.jellyfin.apiKey) {
|
if (!settings.jellyfin || !settings.jellyfin.apiKey) {
|
||||||
console.log('Jellyfin apiKey missing — restoring from defaults');
|
console.log('Jellyfin apiKey missing — restoring from defaults');
|
||||||
settings.jellyfin = JSON.parse(fs.readFileSync(DEFAULTS, 'utf8'));
|
settings.jellyfin = JSON.parse(fs.readFileSync(DEFAULTS, 'utf8'));
|
||||||
fs.writeFileSync(SETTINGS, JSON.stringify(settings, null, 2));
|
|
||||||
console.log('Restored Jellyfin config');
|
console.log('Restored Jellyfin config');
|
||||||
} else {
|
} else {
|
||||||
console.log('Jellyfin config present, skipping restore');
|
console.log('Jellyfin config present, skipping restore');
|
||||||
}
|
}
|
||||||
|
fs.writeFileSync(SETTINGS, JSON.stringify(settings, null, 2));
|
||||||
|
console.log('Settings written successfully');
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|||||||
Reference in New Issue
Block a user