MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / deleteSession

Function deleteSession

apps/desktop/main/database/core.ts:154–182  ·  view source on GitHub ↗
(sessionId: string)

Source from the content-addressed store, hash-verified

152 * 删除会话
153 */
154export function deleteSession(sessionId: string): boolean {
155 const dbPath = getDbPath(sessionId)
156 const walPath = dbPath + '-wal'
157 const shmPath = dbPath + '-shm'
158
159 try {
160 if (fs.existsSync(dbPath)) {
161 fs.unlinkSync(dbPath)
162 }
163 if (fs.existsSync(walPath)) {
164 fs.unlinkSync(walPath)
165 }
166 if (fs.existsSync(shmPath)) {
167 fs.unlinkSync(shmPath)
168 }
169 const cacheDir = getPathProvider().getCacheDir()
170 deleteSessionCache(sessionId, cacheDir)
171 deleteSessionCache(sessionId, path.join(cacheDir, 'query'))
172 deleteSessionCache(sessionId, contactsService.getContactsFactsCacheDir(getPathProvider().getUserDataDir()))
173 deleteSessionCache(
174 sessionId,
175 peopleRelationshipsService.getPeopleRelationshipsFactsCacheDir(getPathProvider().getUserDataDir())
176 )
177 return true
178 } catch (error) {
179 console.error('[Database] Failed to delete session:', error)
180 return false
181 }
182}
183
184/**
185 * 重命名会话

Callers

nothing calls this directly

Calls 6

getPathProviderFunction · 0.90
deleteSessionCacheFunction · 0.90
getDbPathFunction · 0.70
getCacheDirMethod · 0.65
getUserDataDirMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected