From 9717e57c46745ff37d05a9742f70d27695ecdaf6 Mon Sep 17 00:00:00 2001 From: Jozef Kralik Date: Thu, 5 May 2022 10:27:26 +0200 Subject: [PATCH] resource-directory/projection: fix processing snapshot with older version --- resource-aggregate/cqrs/eventstore/projection.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resource-aggregate/cqrs/eventstore/projection.go b/resource-aggregate/cqrs/eventstore/projection.go index 78c30bf4e..ac281d936 100644 --- a/resource-aggregate/cqrs/eventstore/projection.go +++ b/resource-aggregate/cqrs/eventstore/projection.go @@ -35,8 +35,8 @@ func (am *aggregateModel) Update(e EventUnmarshaler) (ignore bool, reload bool) am.LogDebugfFunc("projection.aggregateModel.Update: am.GroupID %v: AggregateID %v: Version %v, hasSnapshot %v", am.groupID, am.aggregateID, am.version, am.hasSnapshot) switch { - case e.Version() == 0 || e.IsSnapshot(): - am.LogDebugfFunc("projection.aggregateModel.Update: e.Version == 0 || e.IsSnapshot()") + case e.Version() == 0 || (e.IsSnapshot() && (!am.hasSnapshot || e.Version() > am.version)): + am.LogDebugfFunc("projection.aggregateModel.Update: e.Version == 0 || (e.IsSnapshot() && (!am.hasSnapshot || e.Version() > am.version)") am.version = e.Version() am.hasSnapshot = true case am.version+1 == e.Version() && am.hasSnapshot: