mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
fix(electron): prevent unified migration from reverting data dir changes
The unified directory migration (needsUnifiedDirMigration) would re-trigger after a user changed their data directory, overwriting config.toml back to the old Electron path. Root cause: no persistent flag tracking whether the migration had already completed. If old databases remained (cleanup failure or timing), it would re-detect and re-run. Fix: - Add `electron_migration_done` flag to config.toml [data] section - Set flag after migrateToUnifiedDirs succeeds and in setCustomDataDir - Check flag at start of needsUnifiedDirMigration to skip if done - Add "migrate to default" button when data is at non-default path - Fix NLP directory path: move from userDataDir to systemDir (~/.chatlab/nlp) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8819dff62c
commit
6ec03d330f
11 files changed
+63
-13
No files matched your search
@@ -35,7 +35,7 @@ function ensureDb(dbManager: DatabaseManager, sessionId: string) {
|
||||
export function registerNlpRoutes(server: FastifyInstance, dbManager: DatabaseManager): void {
|
||||
const pathProvider = (dbManager as any)['pathProvider']
|
||||
if (pathProvider) {
|
||||
const nlpDir = path.join(pathProvider.getUserDataDir(), 'nlp')
|
||||
const nlpDir = path.join(pathProvider.getSystemDir(), 'nlp')
|
||||
initNlpDir(nlpDir)
|
||||
ensureDefaultDict(nlpDir).catch((err) => console.warn('[NLP] Auto-download zh-CN dict failed:', err))
|
||||
}
|
||||
@@ -81,5 +81,5 @@ export function registerNlpRoutes(server: FastifyInstance, dbManager: DatabaseMa
|
||||
|
||||
function resolveNlpDir(dbManager: DatabaseManager): string {
|
||||
const pathProvider = (dbManager as any)['pathProvider']
|
||||
return path.join(pathProvider.getUserDataDir(), 'nlp')
|
||||
return path.join(pathProvider.getSystemDir(), 'nlp')
|
||||
}
|
||||
Reference in new issue
Block a user