/** * Settings key renames (CC1): boolean keys follow the is/has/should/ * convention and folder keys say "folder" (matching the UI) instead of "dir". * The rename is a breaking on-disk change for `settings.json`, so it ships with * this migration, applied in two places: * * - the electron-store shim in settings.ts, which moves any old key found on * disk to its new name once (idempotent — the old key is deleted after); * - backup import (backup.ts), so a backup exported by an older AeroFetch * still restores cleanly. * * Pure and unit-tested (test/settingsMigration.test.ts). New settings keys must * follow the convention up front — this list should only ever grow when a key * is deliberately renamed. */ export const RENAMED_SETTINGS_KEYS: ReadonlyArray = [ ['customCommandEnabled', 'enableCustomCommands'], ['downloadArchive', 'useDownloadArchive'], ['clipboardWatch', 'watchClipboard'], ['sidebarCollapsed', 'isSidebarCollapsed'], ['hardwareAcceleration', 'useHardwareAcceleration'], ['videoDir', 'videoFolder'], ['audioDir', 'audioFolder'] ] /** * Return a copy of `obj` with every legacy key moved to its new name. A value * already present under the NEW name wins (the old key is simply dropped), so * a half-migrated or hand-merged file can't regress a newer value. */ export function migrateSettingsKeys(obj: Record): Record { const out: Record = { ...obj } for (const [oldKey, newKey] of RENAMED_SETTINGS_KEYS) { if (oldKey in out) { if (!(newKey in out)) out[newKey] = out[oldKey] delete out[oldKey] } } return out }