This commit is contained in:
2026-03-20 20:09:36 +01:00
parent 03cbbae48a
commit c378c7a0dd
24 changed files with 336 additions and 392 deletions
@@ -0,0 +1,30 @@
using MassTransit;
using Microsoft.Extensions.Logging;
using Musify.Application.Contracts.Infrastructure;
using Musify.Infrastructure.Messaging.Activities.Arguments;
namespace Musify.Infrastructure.Messaging.Activities
{
public class RemoveFilesActivity(IStorageHandler storageHandler, ILogger<RemoveFilesActivity> logger)
: IExecuteActivity<RemoveFileArguments[]>
{
public async Task<ExecutionResult> Execute(ExecuteContext<RemoveFileArguments[]> executeContext)
{
foreach (var file in executeContext.Arguments)
{
var removeFile = await storageHandler.RemoveFileAsync(
file.BucketName,
file.KeyName,
executeContext.CancellationToken);
if (!removeFile.IsSuccess)
{
string errorMessage = string.Join(";", removeFile.Errors);
logger.LogWarning("Failed to remove file {File} from bucket {BucketName}: {ErrorMessage}",
file, file.BucketName, errorMessage);
}
}
return executeContext.Completed();
}
}
}