Files
Musify/backend/Musify.Infrastructure/MassTransit/Consumers/RoutingSlipCleanUpConsumer.cs
T
AdminandClaude Opus 4.8 8f34ed4874 chore: group .NET into backend/ and drop non-.NET test artifacts
- Move all .NET (6 projects, solution, Directory.*.props, nuget.config)
  into backend/ so the monorepo root can host non-.NET projects later
- Remove throwaway test artifacts: player.html, pl.json
- Trim dead Flutter rules from .gitignore

Build from backend/Musify.slnx: 0 warnings, 0 errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-05 03:43:52 +02:00

48 lines
1.7 KiB
C#

using MassTransit;
using MassTransit.Courier.Contracts;
using Microsoft.Extensions.Logging;
namespace Musify.Infrastructure.MassTransit.Consumers
{
public class RoutingSlipCleanUpConsumer(
ILogger<RoutingSlipCleanUpConsumer> logger) :
IConsumer<RoutingSlipCompleted>,
IConsumer<RoutingSlipFaulted>
{
public const string QueueName = "routing-slip-events";
public Task Consume(ConsumeContext<RoutingSlipCompleted> consumeContext)
=> DeleteFolder(consumeContext.Message.Variables);
public Task Consume(ConsumeContext<RoutingSlipFaulted> consumeContext)
=> DeleteFolder(consumeContext.Message.Variables);
Task DeleteFolder(IDictionary<string, object> variables)
{
if (!variables.TryGetValue(RoutingSlipVariableNames.Workflow.TemporalDirectory, out var pathObject))
return Task.CompletedTask;
var pathString = pathObject.ToString();
if (string.IsNullOrEmpty(pathString))
return Task.CompletedTask;
try
{
Directory.Delete(pathString, recursive: true);
logger.LogInformation("Deleted temporal directory at path {Path}", pathString);
}
catch (DirectoryNotFoundException directoryNotFoundException)
{
logger.LogWarning(directoryNotFoundException, "Temporal directory at path {Path} was not found for deletion", pathString);
}
catch (Exception exception)
{
logger.LogError(exception, "Failed to delete temporal directory at path {Path}", pathString);
throw;
}
return Task.CompletedTask;
}
}
}