Fixed routes and bugs

This commit is contained in:
2026-03-27 23:06:17 +01:00
parent 8e678435f4
commit 744ce1ae96
18 changed files with 72 additions and 101 deletions
@@ -13,6 +13,8 @@ namespace Musify.Infrastructure.MassTransit.Activities
{
public const string ExecuteEndpointName = "generate-picture-workflow-paths";
internal const string ResizedPictureFileExtension = ".webp";
public async Task<ExecutionResult> Execute(ExecuteContext<GeneratePictureWorkflowPathsArguments> executeContext)
{
var processId = await processTrackingStore.GetOrCreateProcessAsync(
@@ -32,19 +34,16 @@ namespace Musify.Infrastructure.MassTransit.Activities
try
{
var destinationFolderName = Guid.NewGuid().ToString();
var originalFileName = Path.GetFileName(executeContext.Arguments.SourceKeyName);
var sourceFileExtension = Path.GetExtension(originalFileName);
var workingDirectory = Path.Combine(executeContext.Arguments.TemporaryRootDirectory, destinationFolderName);
var sourceFileName = Guid.NewGuid().ToString() + sourceFileExtension;
var smallPictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
var mediumPictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
var largePictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
var sourceFilePath = Path.Combine(workingDirectory, sourceFileName);
var smallPictureFilePath = Path.Combine(workingDirectory, smallPictureFileName);
var mediumPictureFilePath = Path.Combine(workingDirectory, mediumPictureFileName);
var largePictureFilePath = Path.Combine(workingDirectory, largePictureFileName);
var sourceFilePath = Path.Combine(
workingDirectory, Guid.NewGuid().ToString() + Path.GetExtension(executeContext.Arguments.SourceKeyName));
var smallPictureFilePath = Path.Combine(
workingDirectory, Guid.NewGuid().ToString() + ResizedPictureFileExtension);
var mediumPictureFilePath = Path.Combine(
workingDirectory, Guid.NewGuid().ToString() + ResizedPictureFileExtension);
var largePictureFilePath = Path.Combine(
workingDirectory, Guid.NewGuid().ToString() + ResizedPictureFileExtension);
Directory.CreateDirectory(workingDirectory);
@@ -33,10 +33,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
executeContext.CancellationToken);
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
var destinationFilePath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
if (string.IsNullOrWhiteSpace(sourceFilePath) || string.IsNullOrWhiteSpace(destinationFilePath))
throw new InvalidOperationException("Resize activity requires source and destination file path variables.");
ArgumentNullException.ThrowIfNull(destinationFilePath, nameof(destinationFilePath));
try
{
@@ -48,7 +47,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
await using var fileStream = File.OpenRead(sourceFilePath);
var resizedPicture = await pictureHandler.ResizePictureAsync(
var resizedPicture = await pictureHandler.ResizePictureAsWebpAsync(
fileStream,
executeContext.Arguments.Width,
executeContext.Arguments.Height,
@@ -31,6 +31,13 @@ namespace Musify.Infrastructure.MassTransit.Activities
0,
executeContext.CancellationToken);
var smallResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.SmallPictureVariableName);
ArgumentNullException.ThrowIfNull(smallResizedVariable, nameof(smallResizedVariable));
var mediumResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.MediumPictureVariableName);
ArgumentNullException.ThrowIfNull(mediumResizedVariable, nameof(mediumResizedVariable));
var largeResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.LargePictureVariableName);
ArgumentNullException.ThrowIfNull(largeResizedVariable, nameof(largeResizedVariable));
try
{
var playList = await database.PlayLists.FindAsync(
@@ -52,9 +59,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
playList.LargePictureKeyName);
playList.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKeyName);
playList.SmallPictureKeyName = Path.GetFileName(executeContext.Arguments.SmallPictureKeyName);
playList.MediumPictureKeyName = Path.GetFileName(executeContext.Arguments.MediumPictureKeyName);
playList.LargePictureKeyName = Path.GetFileName(executeContext.Arguments.LargePictureKeyName);
playList.SmallPictureKeyName = Path.GetFileName(smallResizedVariable);
playList.MediumPictureKeyName = Path.GetFileName(mediumResizedVariable);
playList.LargePictureKeyName = Path.GetFileName(largeResizedVariable);
database.PlayLists.Update(playList);
await database.SaveChangesAsync(executeContext.CancellationToken);
@@ -31,6 +31,13 @@ namespace Musify.Infrastructure.MassTransit.Activities
0,
executeContext.CancellationToken);
var smallResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.SmallPictureVariableName);
ArgumentNullException.ThrowIfNull(smallResizedVariable, nameof(smallResizedVariable));
var mediumResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.MediumPictureVariableName);
ArgumentNullException.ThrowIfNull(mediumResizedVariable, nameof(mediumResizedVariable));
var largeResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.LargePictureVariableName);
ArgumentNullException.ThrowIfNull(largeResizedVariable, nameof(largeResizedVariable));
try
{
var track = await database.Tracks.FindAsync(
@@ -52,9 +59,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
track.LargePictureKeyName);
track.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKeyName);
track.SmallPictureKeyName = Path.GetFileName(executeContext.Arguments.SmallPictureKeyName);
track.MediumPictureKeyName = Path.GetFileName(executeContext.Arguments.MediumPictureKeyName);
track.LargePictureKeyName = Path.GetFileName(executeContext.Arguments.LargePictureKeyName);
track.SmallPictureKeyName = Path.GetFileName(smallResizedVariable);
track.MediumPictureKeyName = Path.GetFileName(mediumResizedVariable);
track.LargePictureKeyName = Path.GetFileName(largeResizedVariable);
database.Tracks.Update(track);
await database.SaveChangesAsync(executeContext.CancellationToken);