1
0
mirror of https://github.com/bitwarden/server synced 2025-12-17 16:53:23 +00:00

Move delete many complexity to service

This commit is contained in:
Hinton
2025-11-14 14:45:02 +01:00
parent d9b5ab2f67
commit fcdbfcb601
3 changed files with 50 additions and 48 deletions

View File

@@ -79,6 +79,34 @@ public class SceneService(
return new { PlayId = playId };
}
public async Task DestroyScenes(IEnumerable<string> playIds)
{
var exceptions = new List<Exception>();
var deleteTasks = playIds.Select(async playId =>
{
try
{
await DestroyScene(playId);
}
catch (Exception ex)
{
lock (exceptions)
{
exceptions.Add(ex);
}
logger.LogError(ex, "Error deleting seeded data: {PlayId}", playId);
}
});
await Task.WhenAll(deleteTasks);
if (exceptions.Count > 0)
{
throw new AggregateException("One or more errors occurred while deleting seeded data", exceptions);
}
}
private async Task<SceneResult<object?>> ExecuteSceneMethod(string templateName, JsonElement? arguments, string methodName)
{
try