Rename variables

This commit is contained in:
2026-03-28 03:27:31 +01:00
parent ffaf9990df
commit d2a1807883
42 changed files with 226 additions and 261 deletions
@@ -31,22 +31,22 @@ namespace Musify.Infrastructure.MassTransit.Activities
0,
executeContext.CancellationToken);
var destinationPath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
var destinationPath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariable);
ArgumentNullException.ThrowIfNull(destinationPath, nameof(destinationPath));
try
{
var getFile = await storageHandler.GetFileAsync(
executeContext.Arguments.BucketName,
executeContext.Arguments.KeyName,
executeContext.Arguments.Bucket,
executeContext.Arguments.Key,
executeContext.CancellationToken);
if (!getFile.IsSuccess)
{
var errorMessage = string.Join("; ", getFile.Errors);
logger.LogWarning("Failed to download file from bucket. Bucket: {BucketName}, Key: {KeyName}, Errors: {Errors}",
executeContext.Arguments.BucketName,
executeContext.Arguments.KeyName,
executeContext.Arguments.Bucket,
executeContext.Arguments.Key,
errorMessage);
throw new Exception(errorMessage);
}
@@ -64,8 +64,8 @@ namespace Musify.Infrastructure.MassTransit.Activities
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
return executeContext.Completed(new DownloadFileFromBucketLog(
executeContext.Arguments.BucketName,
executeContext.Arguments.KeyName,
executeContext.Arguments.Bucket,
executeContext.Arguments.Key,
destinationPath));
}
catch (Exception exception)
@@ -33,16 +33,16 @@ namespace Musify.Infrastructure.MassTransit.Activities
try
{
var removeFile = await storageHandler.RemoveFileAsync(
executeContext.Arguments.BucketName,
executeContext.Arguments.KeyName,
executeContext.Arguments.Bucket,
executeContext.Arguments.Key,
executeContext.CancellationToken);
if (!removeFile.IsSuccess)
{
var errorMessage = string.Join("; ", removeFile.Errors);
logger.LogWarning("Failed to remove file {KeyName} from bucket {BucketName}. Errors: {Errors}",
executeContext.Arguments.KeyName,
executeContext.Arguments.BucketName,
executeContext.Arguments.Key,
executeContext.Arguments.Bucket,
errorMessage);
}
@@ -52,8 +52,8 @@ namespace Musify.Infrastructure.MassTransit.Activities
catch (Exception exception)
{
logger.LogError(exception, "Error removing file {KeyName} from bucket {BucketName}",
executeContext.Arguments.KeyName,
executeContext.Arguments.BucketName);
executeContext.Arguments.Key,
executeContext.Arguments.Bucket);
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
throw;
}
@@ -31,22 +31,21 @@ namespace Musify.Infrastructure.MassTransit.Activities
0,
executeContext.CancellationToken);
var folderPath = executeContext.GetVariable<string>(executeContext.Arguments.SourceDirectoryVariableName);
var folderPath = executeContext.GetVariable<string>(executeContext.Arguments.SourceDirectoryVariable);
ArgumentNullException.ThrowIfNull(folderPath, nameof(folderPath));
var destinationKeyName = executeContext.Arguments.DestinationKeyName;
ArgumentNullException.ThrowIfNull(destinationKeyName, nameof(destinationKeyName));
var destinationKey = executeContext.Arguments.DestinationKey;
ArgumentNullException.ThrowIfNull(destinationKey, nameof(destinationKey));
try
{
var uploadedKeys = Directory.GetFiles(folderPath)
.Select(file => Path.Combine(destinationKeyName, Path.GetFileName(file)))
.Select(file => Path.Combine(destinationKey, Path.GetFileName(file)))
.ToArray();
var transferFilesResult = await storageHandler.TransferFilesAsync(
folderPath,
executeContext.Arguments.DestinationBucketName,
destinationKeyName,
executeContext.Arguments.DestinationBucket,
destinationKey,
executeContext.CancellationToken);
if (!transferFilesResult.IsSuccess)
@@ -54,8 +53,8 @@ namespace Musify.Infrastructure.MassTransit.Activities
var errorMessage = string.Join("; ", transferFilesResult.Errors);
logger.LogWarning("Failed to transfer files from {FolderPath} to bucket {DestinationBucketName}, key {DestinationKeyName}. Errors: {Errors}",
folderPath,
executeContext.Arguments.DestinationBucketName,
destinationKeyName,
executeContext.Arguments.DestinationBucket,
destinationKey,
errorMessage);
throw new Exception(errorMessage);
}
@@ -67,7 +66,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
{
logger.LogError(exception, "Error transferring files from {FolderPath} to bucket {DestinationBucketName}",
folderPath,
executeContext.Arguments.DestinationBucketName);
executeContext.Arguments.DestinationBucket);
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
throw;
}
@@ -80,7 +79,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
foreach (var uploadedKey in compensateContext.Log.UploadedKeys)
{
await storageHandler.RemoveFileAsync(
compensateContext.Log.DestinationBucketName,
compensateContext.Log.DestinationBucket,
uploadedKey,
compensateContext.CancellationToken);
}
@@ -89,7 +88,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
}
catch (Exception exception)
{
logger.LogError(exception, "Error compensating transferred files to bucket {DestinationBucketName}", compensateContext.Log.DestinationBucketName);
logger.LogError(exception, "Error compensating transferred files to bucket {DestinationBucketName}", compensateContext.Log.DestinationBucket);
return compensateContext.Failed(exception);
}
}
@@ -31,7 +31,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
0,
executeContext.CancellationToken);
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.FilePathVariableName);
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.FilePathVariable);
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
var fileName = Path.GetFileName(sourceFilePath);
@@ -39,7 +39,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
{
var uploadResult = await storageHandler.UploadFileAsync(
sourceFilePath,
executeContext.Arguments.DestinationBucketName,
executeContext.Arguments.DestinationBucket,
Path.Combine(executeContext.Arguments.DestinationRoute, fileName),
executeContext.CancellationToken);
@@ -47,7 +47,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
{
var errors = string.Join("; ", uploadResult.Errors);
logger.LogWarning("Failed to upload file to bucket. Bucket: {BucketName}, Key: {KeyName}, Errors: {Errors}",
executeContext.Arguments.DestinationBucketName,
executeContext.Arguments.DestinationBucket,
executeContext.Arguments.DestinationRoute,
errors);
throw new Exception(errors);
@@ -55,7 +55,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
return executeContext.CompletedWithVariables(new UploadFileToBucketLog(
executeContext.Arguments.DestinationBucketName,
executeContext.Arguments.DestinationBucket,
executeContext.Arguments.DestinationRoute));
}
catch (Exception exception)
@@ -71,14 +71,14 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
try
{
var uploadResult = await storageHandler.RemoveFileAsync(
compensateContext.Log.DestinationBucketName,
compensateContext.Log.DestinationKeyName,
compensateContext.Log.DestinationBucket,
compensateContext.Log.DestinationKey,
compensateContext.CancellationToken);
if (!uploadResult.IsSuccess)
{
var errors = string.Join("; ", uploadResult.Errors);
var errorMessage = $"Failed to remove file from bucket during compensation. Bucket: {compensateContext.Log.DestinationBucketName}, Key: {compensateContext.Log.DestinationKeyName}, Errors: {errors}";
var errorMessage = $"Failed to remove file from bucket during compensation. Bucket: {compensateContext.Log.DestinationBucket}, Key: {compensateContext.Log.DestinationKey}, Errors: {errors}";
logger.LogError(errorMessage);
return compensateContext.Failed(new Exception(errorMessage));
@@ -88,8 +88,8 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
catch (Exception exception)
{
logger.LogError(exception, "An error occurred while compensating upload file to bucket activity for bucket {BucketName} and key {KeyName}",
compensateContext.Log.DestinationBucketName,
compensateContext.Log.DestinationKeyName);
compensateContext.Log.DestinationBucket,
compensateContext.Log.DestinationKey);
return compensateContext.Failed(exception);
}
}