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

Function isUserDataDirSafeToUse

packages/node-runtime/src/data-dir-switch.ts:131–141  ·  view source on GitHub ↗
(dirPath: string)

Source from the content-addressed store, hash-verified

129}
130
131export function isUserDataDirSafeToUse(dirPath: string): boolean {
132 if (!fs.existsSync(dirPath)) return true
133
134 try {
135 const entries = fs.readdirSync(dirPath)
136 if (entries.length === 0) return true
137 return hasChatLabUserDataStructure(entries) || hasChatLabDatabaseFiles(dirPath, entries)
138 } catch {
139 return false
140 }
141}
142
143export function isDirectoryEmptyOrMissing(dirPath: string): boolean {
144 if (!fs.existsSync(dirPath)) return true

Callers 2

createNodeDataDirSwitchFunction · 0.85
setCustomDataDirFunction · 0.85

Calls 2

hasChatLabDatabaseFilesFunction · 0.85

Tested by

no test coverage detected