Rollback every committed transaction in a session, newest first.
(sessionId: string)
| 356 | } |
| 357 | |
| 358 | async begin(sessionId: string, toolCallId?: string, cwd?: string): Promise<Transaction> { |
| 359 | await fs.mkdir(this.blobsDir, { recursive: true }); |
| 360 | const row = this.getNextIdStmt.get() as { value: number }; |
| 361 | const txnId = row.value; |
| 362 | this.incrementStmt.run(); |
| 363 | return new Transaction(txnId, this, sessionId, toolCallId, cwd); |
| 364 | } |
| 365 | |
| 366 | persistOps( |
| 367 | txnId: number, |
| 368 | sessionId: string, |
| 369 | ops: JournaledOp[], |
| 370 | gitSha: string | null, |
| 371 | toolCallId: string | undefined, |
| 372 | summary: string | undefined, |
| 373 | gitStatus?: string, |
| 374 | gitFailReason?: string | null, |
| 375 | ): void { |
| 376 | const tx = this.db.transaction(() => { |
| 377 | for (const op of ops) { |
| 378 | this.writeStmt.run( |
| 379 | txnId, sessionId, op.operation, op.path, |
| 380 | op.beforeHash, op.afterHash, gitSha, gitStatus ?? null, gitFailReason ?? null, |
| 381 | toolCallId ?? null, summary ?? null, |
| 382 | ); |
| 383 | } |
| 384 | }); |
| 385 | tx(); |
| 386 | } |
| 387 | |
| 388 | markRolledBack(txnId: number): void { |
| 389 | this.markRolledBackStmt.run(txnId); |
| 390 | } |
| 391 | |
| 392 | async storeBlob(hash: string, content: string): Promise<void> { |
| 393 | const blobPath = path.join(this.blobsDir, hash.slice(0, 2), hash); |
no test coverage detected