From 39c92761774bb4fee236f18efe74dbcc0c8b1538 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Tue, 16 Jan 2024 13:21:50 +0100 Subject: [PATCH] Fix deleter. --- .../Assets/MongoShardedAssetRepository.cs | 2 +- .../Contents/MongoShardedContentRepository.cs | 2 +- .../Text/MongoShardedTextIndex.cs | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoShardedAssetRepository.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoShardedAssetRepository.cs index f2ebbca150..d6652dca33 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoShardedAssetRepository.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoShardedAssetRepository.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets; -public sealed class MongoShardedAssetRepository : ShardedSnapshotStore, IAssetRepository +public sealed class MongoShardedAssetRepository : ShardedSnapshotStore, IAssetRepository, IDeleter { public MongoShardedAssetRepository(IShardingStrategy sharding, Func factory) : base(sharding, factory) diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoShardedContentRepository.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoShardedContentRepository.cs index a55296fdb6..817ae439b1 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoShardedContentRepository.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoShardedContentRepository.cs @@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents; -public sealed class MongoShardedContentRepository : ShardedSnapshotStore, IContentRepository +public sealed class MongoShardedContentRepository : ShardedSnapshotStore, IContentRepository, IDeleter { public MongoShardedContentRepository(IShardingStrategy sharding, Func factory) : base(sharding, factory) diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoShardedTextIndex.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoShardedTextIndex.cs index 92b0e2f64e..2ee73e1ccf 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoShardedTextIndex.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Text/MongoShardedTextIndex.cs @@ -13,7 +13,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Text; -public sealed class MongoShardedTextIndex : ShardedService>, ITextIndex where T : class +public sealed class MongoShardedTextIndex : ShardedService>, ITextIndex, IDeleter where T : class { public MongoShardedTextIndex(IShardingStrategy sharding, Func> factory) : base(sharding, factory) @@ -52,4 +52,15 @@ public async Task ExecuteAsync(IndexCommand[] commands, { return Shard(app.Id).SearchAsync(app, query, scope, ct); } + + public async Task DeleteAppAsync(App app, + CancellationToken ct) + { + var shard = Shard(app.Id) as IDeleter; + + if (shard != null) + { + await shard.DeleteAppAsync(app, ct); + } + } }