diff --git a/backend/src/Squidex.Infrastructure.Azure/EventSourcing/StreamPosition.cs b/backend/src/Squidex.Infrastructure.Azure/EventSourcing/StreamPosition.cs index b35ffdf0d..514bf5833 100644 --- a/backend/src/Squidex.Infrastructure.Azure/EventSourcing/StreamPosition.cs +++ b/backend/src/Squidex.Infrastructure.Azure/EventSourcing/StreamPosition.cs @@ -15,6 +15,8 @@ namespace Squidex.Infrastructure.EventSourcing private static readonly ObjectPool StringBuilderPool = new DefaultObjectPool(new StringBuilderPooledObjectPolicy()); + public static readonly StreamPosition Empty = new StreamPosition(); + public long Timestamp { get; } public long CommitOffset { get; } @@ -59,13 +61,16 @@ namespace Squidex.Infrastructure.EventSourcing { var parts = position.Split('-'); - return new StreamPosition( + if (parts.Length == 3) + { + return new StreamPosition( long.Parse(parts[0]), long.Parse(parts[1]), long.Parse(parts[2])); + } } - return new StreamPosition(0, -1, -1); + return Empty; } } } diff --git a/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/StreamPosition.cs b/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/StreamPosition.cs index 3c251a0ab..e6e946c67 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/StreamPosition.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/StreamPosition.cs @@ -16,7 +16,9 @@ namespace Squidex.Infrastructure.EventSourcing private static readonly ObjectPool StringBuilderPool = new DefaultObjectPool(new StringBuilderPooledObjectPolicy()); - private static readonly BsonTimestamp EmptyTimestamp = new BsonTimestamp(946681200, 0); + private static readonly BsonTimestamp EmptyTimestamp = new BsonTimestamp(0, 0); + + public static readonly StreamPosition Empty = new StreamPosition(EmptyTimestamp, -1, -1); public BsonTimestamp Timestamp { get; } @@ -64,13 +66,16 @@ namespace Squidex.Infrastructure.EventSourcing { var parts = position.Split('-'); - return new StreamPosition( - new BsonTimestamp(int.Parse(parts[0]), int.Parse(parts[1])), - long.Parse(parts[2]), - long.Parse(parts[3])); + if (parts.Length == 4) + { + return new StreamPosition( + new BsonTimestamp(int.Parse(parts[0]), int.Parse(parts[1])), + long.Parse(parts[2]), + long.Parse(parts[3])); + } } - return new StreamPosition(EmptyTimestamp, -1, -1); + return Empty; } } }