()
| 585 | * Electron 启动并写入了默认值 ~/.chatlab/data,导致迁移被跳过。 |
| 586 | */ |
| 587 | export function needsUnifiedDirMigration(): boolean { |
| 588 | const config = loadConfig() |
| 589 | if (config.data.electron_migration_done) return false |
| 590 | |
| 591 | const oldDataDir = resolveOldElectronDataDir() |
| 592 | const oldDbDir = path.join(oldDataDir, 'databases') |
| 593 | if (!fs.existsSync(oldDbDir)) return false |
| 594 | |
| 595 | const hasDb = fs.readdirSync(oldDbDir).some((f) => f.endsWith('.db')) |
| 596 | if (!hasDb) return false |
| 597 | |
| 598 | const currentUserDataDir = config.data.user_data_dir || getDefaultUserDataDir() |
| 599 | if (path.resolve(currentUserDataDir) === path.resolve(oldDataDir)) return false |
| 600 | |
| 601 | return true |
| 602 | } |
| 603 | |
| 604 | /** |
| 605 | * 解析 Electron 旧数据目录(考虑 storage.json 自定义路径) |
no test coverage detected