fix(infra): repair TransferFiles compensation + tidy MassTransit consistency
Fix (recoverability bug): - TransferFilesToBucketActivity returned Completed() with no log, so its compensation could never delete the transferred files (orphaned objects on fault). IStorageService.TransferFilesAsync now returns the real uploaded keys; the activity logs them so Compensate can remove them. Also drops the Path.Combine key recomputation (produced backslash keys on Windows). Consistency / DRY: - Normalize all courier activities to internal + folder-based namespaces (several were public and in the flat .Activities namespace) - Extract the duplicated exponential retry into UseStandardRetry - Unify endpoint-name logic into a single EndpointHelper (remove the parallel MassTransitEndpointNames helper) Build: 0 warnings, 0 errors.
This commit is contained in:
+8
-9
@@ -4,9 +4,9 @@ using Musify.Application.Contracts;
|
||||
using Musify.Infrastructure.MassTransit.Arguments;
|
||||
using Musify.Infrastructure.MassTransit.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.MassTransit.Activities
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
{
|
||||
public class TransferFilesToBucketActivity(
|
||||
internal class TransferFilesToBucketActivity(
|
||||
IStorageService storageHandler,
|
||||
ILogger<TransferFilesToBucketActivity> logger)
|
||||
: IActivity<TransferFilesToBucketArguments, TransferFilesToBucketLog>
|
||||
@@ -22,16 +22,15 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
|
||||
try
|
||||
{
|
||||
var uploadedKeys = Directory.GetFiles(folderPath)
|
||||
.Select(file => Path.Combine(destinationKey, Path.GetFileName(file)))
|
||||
.ToArray();
|
||||
|
||||
await storageHandler.TransferFilesAsync(
|
||||
var uploadedKeys = await storageHandler.TransferFilesAsync(
|
||||
folderPath,
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
destinationKey,
|
||||
executeContext.CancellationToken);
|
||||
return executeContext.Completed();
|
||||
|
||||
return executeContext.Completed(new TransferFilesToBucketLog(
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
uploadedKeys.ToArray()));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -63,4 +62,4 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ using Musify.Infrastructure.MassTransit.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
{
|
||||
public class UploadFileToBucketActivity(IStorageService storageHandler,
|
||||
internal class UploadFileToBucketActivity(IStorageService storageHandler,
|
||||
ILogger<UploadFileToBucketActivity> logger)
|
||||
: IActivity<UploadFileToBucketArguments, UploadFileToBucketLog>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user