(sessionId: string, newName: string)
| 185 | * 重命名会话 |
| 186 | */ |
| 187 | export function renameSession(sessionId: string, newName: string): boolean { |
| 188 | const dbPath = getDbPath(sessionId) |
| 189 | if (!fs.existsSync(dbPath)) return false |
| 190 | |
| 191 | const db = new Database(dbPath) |
| 192 | db.pragma('journal_mode = WAL') |
| 193 | try { |
| 194 | coreRenameSession(new BetterSqliteAdapter(db), newName) |
| 195 | return true |
| 196 | } catch (error) { |
| 197 | console.error('[Database] Failed to rename session:', error) |
| 198 | return false |
| 199 | } finally { |
| 200 | db.close() |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * 获取数据库存储目录 |