()
| 738 | * This acts as a safety net in case migration was skipped or config was overwritten. |
| 739 | */ |
| 740 | export function verifyDataPath(): void { |
| 741 | const currentDir = getUserDataDir() |
| 742 | const currentDbDir = path.join(currentDir, 'databases') |
| 743 | const hasCurrentDbs = fs.existsSync(currentDbDir) && fs.readdirSync(currentDbDir).some((f) => f.endsWith('.db')) |
| 744 | |
| 745 | if (hasCurrentDbs) return |
| 746 | |
| 747 | const oldDir = getElectronLegacyDataDir() |
| 748 | if (path.resolve(currentDir) === path.resolve(oldDir)) return |
| 749 | |
| 750 | const oldDbDir = path.join(oldDir, 'databases') |
| 751 | if (!fs.existsSync(oldDbDir)) return |
| 752 | |
| 753 | const hasOldDbs = fs.readdirSync(oldDbDir).some((f) => f.endsWith('.db')) |
| 754 | if (!hasOldDbs) return |
| 755 | |
| 756 | console.warn( |
| 757 | `[Paths] Data path mismatch: configured dir ${currentDir} has no databases, but old path ${oldDir} does. Auto-correcting config.toml.` |
| 758 | ) |
| 759 | writeConfigField('data', 'user_data_dir', oldDir) |
| 760 | _userDataDir = oldDir |
| 761 | } |
no test coverage detected