MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / verifyDataPath

Function verifyDataPath

apps/desktop/main/paths.ts:740–761  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

738 * This acts as a safety net in case migration was skipped or config was overwritten.
739 */
740export 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}

Callers 1

initMethod · 0.90

Calls 4

writeConfigFieldFunction · 0.90
getUserDataDirFunction · 0.85
getElectronLegacyDataDirFunction · 0.85
warnMethod · 0.65

Tested by

no test coverage detected