| 409 | "SELECT data FROM note_versions WHERE note_id = ? AND storage = 'r2'", noteId |
| 410 | ).toArray() as any[]; |
| 411 | this.sql.exec("DELETE FROM note_versions WHERE note_id = ?", noteId); |
| 412 | this.sql.exec("DELETE FROM note_branches WHERE note_id = ?", noteId); |
| 413 | for (let i = 0; i < rows.length; i += 1000) { |
| 414 | const keys = rows.slice(i, i + 1000).map((r) => r.data as string); |
| 415 | try { await this.bucket.delete(keys); } catch (e) { |
| 416 | console.error(`Failed to delete version objects for note ${noteId}:`, e); |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | private contentHash(content: string): string { |
| 422 | let hash = 5381; |
| 423 | for (let i = 0; i < content.length; i++) { |