Skip to content

Commit 31dc78b

Browse files
authored
Move HasCommit check inside lock in DataModel.Add (#66)
1 parent 930b61a commit 31dc78b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/SIL.Harmony/DataModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ private Commit NewCommit(Guid commitId, Guid clientId, CommitMetadata? commitMet
114114
private async Task Add(Commit commit)
115115
{
116116
await using var repo = await _crdtRepositoryFactory.CreateRepository();
117-
if (await repo.HasCommit(commit.Id)) return;
118117
using var locked = await repo.Lock();
118+
if (await repo.HasCommit(commit.Id)) return;
119119
repo.ClearChangeTracker();
120120

121121
await using var transaction = repo.IsInTransaction ? null : await repo.BeginTransactionAsync();

0 commit comments

Comments
 (0)