Skip to content

Commit 33ff416

Browse files
authored
Use UsingSnapshotting property during recovery (#2244)
1 parent 4fa10f6 commit 33ff416

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Proto.Persistence/Persistence.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ private Persistence(
4545
/// </summary>
4646
public long Index { get; private set; } = -1;
4747

48-
private bool UsingSnapshotting => _applySnapshot is not null; //TODO: why not used?
49-
private bool UsingEventSourcing => _applyEvent is not null;
48+
private bool UsingSnapshotting => _applySnapshot is not null;
49+
private bool UsingEventSourcing => _applyEvent is not null;
5050

5151
/// <summary>
5252
/// Initializes <see cref="Persistence" /> with event storing only.
@@ -216,13 +216,13 @@ Func<object> getSnapshot
216216
/// <returns></returns>
217217
public async Task RecoverStateAsync()
218218
{
219-
var (snapshot, lastSnapshotIndex) = await _snapshotStore.GetSnapshotAsync(_actorId).ConfigureAwait(false);
220-
221-
if (snapshot is not null && _applySnapshot is not null)
222-
{
223-
Index = lastSnapshotIndex;
224-
_applySnapshot(new RecoverSnapshot(snapshot, lastSnapshotIndex));
225-
}
219+
var (snapshot, lastSnapshotIndex) = await _snapshotStore.GetSnapshotAsync(_actorId).ConfigureAwait(false);
220+
221+
if (snapshot is not null && UsingSnapshotting)
222+
{
223+
Index = lastSnapshotIndex;
224+
_applySnapshot!(new RecoverSnapshot(snapshot, lastSnapshotIndex));
225+
}
226226

227227
var fromEventIndex = Index + 1;
228228

0 commit comments

Comments
 (0)