Experimental changes
This commit is contained in:
@@ -8,7 +8,7 @@ using Musify.Infrastructure.MassTransit.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
{
|
||||
public class UploadFileToBucketActivity(IStorageHandler storageHandler,
|
||||
public class UploadFileToBucketActivity(IStorageService storageHandler,
|
||||
ILogger<UploadFileToBucketActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IActivity<UploadFileToBucketArguments, UploadFileToBucketLog>
|
||||
@@ -37,22 +37,12 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
|
||||
try
|
||||
{
|
||||
var uploadResult = await storageHandler.UploadFileAsync(
|
||||
await storageHandler.UploadFileAsync(
|
||||
sourceFilePath,
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
Path.Combine(executeContext.Arguments.DestinationRoute, fileName),
|
||||
executeContext.CancellationToken);
|
||||
|
||||
if (!uploadResult.IsSuccess)
|
||||
{
|
||||
var errors = string.Join("; ", uploadResult.Errors);
|
||||
logger.LogWarning("Failed to upload file to bucket {Bucket}/{Route}: {Errors}",
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
executeContext.Arguments.DestinationRoute,
|
||||
errors);
|
||||
throw new Exception(errors);
|
||||
}
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.CompletedWithVariables(new UploadFileToBucketLog(
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
@@ -70,19 +60,10 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
{
|
||||
try
|
||||
{
|
||||
var uploadResult = await storageHandler.RemoveFileAsync(
|
||||
await storageHandler.RemoveFileAsync(
|
||||
compensateContext.Log.DestinationBucket,
|
||||
compensateContext.Log.DestinationKey,
|
||||
compensateContext.CancellationToken);
|
||||
|
||||
if (!uploadResult.IsSuccess)
|
||||
{
|
||||
var errors = string.Join("; ", uploadResult.Errors);
|
||||
logger.LogError("Failed to remove file from bucket during compensation. Bucket: {Bucket}, Key: {Key}, Errors: {Errors}",
|
||||
compensateContext.Log.DestinationBucket, compensateContext.Log.DestinationKey, errors);
|
||||
|
||||
return compensateContext.Failed(new Exception($"Failed to remove file from bucket during compensation. Bucket: {compensateContext.Log.DestinationBucket}, Key: {compensateContext.Log.DestinationKey}, Errors: {errors}"));
|
||||
}
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
Reference in New Issue
Block a user