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
@@ -32,10 +32,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
executeContext.CancellationToken);
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
var workingDirectory = executeContext.GetVariable<string>(executeContext.Arguments.WorkingDirectoryVariableName);
if (string.IsNullOrWhiteSpace(sourceFilePath) || string.IsNullOrWhiteSpace(workingDirectory))
throw new InvalidOperationException("Transcode activity requires source file path and working directory variables.");
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
try
{
@@ -4,7 +4,6 @@ using Musify.Application.Contracts.Infrastructure;
using Musify.Domain.Entities;
using Musify.Infrastructure.MassTransit.Arguments;
using Musify.Infrastructure.MassTransit.Logs;
using Musify.Infrastructure.MassTransit.Activities;
namespace Musify.Infrastructure.MassTransit.Activities.Audio
{
@@ -32,9 +32,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
executeContext.CancellationToken);
var destinationPath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
if (string.IsNullOrWhiteSpace(destinationPath))
throw new InvalidOperationException(
$"Download activity requires variable '{executeContext.Arguments.DestinationFilePathVariableName}' with destination file path.");
ArgumentNullException.ThrowIfNull(destinationPath, nameof(destinationPath));
try
{
@@ -32,16 +32,10 @@ namespace Musify.Infrastructure.MassTransit.Activities
executeContext.CancellationToken);
var folderPath = executeContext.GetVariable<string>(executeContext.Arguments.SourceDirectoryVariableName);
if (string.IsNullOrWhiteSpace(folderPath))
throw new InvalidOperationException(
$"Transfer activity requires variable '{executeContext.Arguments.SourceDirectoryVariableName}' with source directory path.");
ArgumentNullException.ThrowIfNull(folderPath, nameof(folderPath));
var destinationKeyName = executeContext.Arguments.DestinationKeyName;
if (string.IsNullOrWhiteSpace(destinationKeyName) && !string.IsNullOrWhiteSpace(executeContext.Arguments.DestinationKeyNameVariableName))
destinationKeyName = executeContext.GetVariable<string>(executeContext.Arguments.DestinationKeyNameVariableName);
if (string.IsNullOrWhiteSpace(destinationKeyName))
throw new InvalidOperationException("Transfer activity requires a destination key name from arguments or variables.");
ArgumentNullException.ThrowIfNull(destinationKeyName, nameof(destinationKeyName));
try
{
@@ -32,8 +32,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
executeContext.CancellationToken);
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.FilePathVariableName);
if (string.IsNullOrEmpty(sourceFilePath))
throw new InvalidOperationException($"Upload activity requires variable '{executeContext.Arguments.FilePathVariableName}' with source file path.");
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
var fileName = Path.GetFileName(sourceFilePath);
try
@@ -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);