Skip to content

Commit

Permalink
fix accidental overdeletion
Browse files Browse the repository at this point in the history
  • Loading branch information
a-type committed Apr 12, 2024
1 parent a3000f6 commit 2add1d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-toes-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@verdant-web/server': patch
---

Important: fixes accidental operation deletion in rebasing logic
19 changes: 10 additions & 9 deletions packages/server/src/storage/sql/SqlOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ export class SqlOperations implements OperationStorage {
libraryId: string,
operations: Operation[],
): Promise<void> => {
await this.db
.deleteFrom('OperationHistory')
.where('libraryId', '=', libraryId)
.where(
'oid',
'in',
operations.map((o) => o.oid),
)
.execute();
await this.db.transaction().execute(async (tx) => {
for (const item of operations) {
await tx
.deleteFrom('OperationHistory')
.where('libraryId', '=', libraryId)
.where('oid', '=', item.oid)
.where('timestamp', '=', item.timestamp)
.execute();
}
});
};
}

0 comments on commit 2add1d9

Please sign in to comment.