From 7709fe737f3239de5506e6135fbe0b7575dd83ce Mon Sep 17 00:00:00 2001 From: XShine555 Date: Sat, 28 Mar 2026 15:32:36 +0100 Subject: [PATCH] Renames and changes --- .../Infrastructure/IStorageHandler.cs | 14 +-- .../Handlers/CreatePlayListCommandHandler.cs | 12 +-- .../Handlers/DeletePlayListCommandHandler.cs | 20 ++-- .../Handlers/UpdatePlayListCommandHandler.cs | 24 ++--- .../PlayLists/Responses/PlayListResponse.cs | 6 +- .../Handler/CreateTrackCommandHandler.cs | 16 ++-- .../Handlers/CreateUserCommandHandler.cs | 2 - Domain/Entities/PlayList.cs | 10 +- Domain/Entities/Track.cs | 12 +-- Domain/Entities/Upload.cs | 4 +- Infrastructure/Audio/AudioTranscoder.cs | 34 +++---- .../Identity/KeycloakUserService.cs | 4 +- .../GenerateAudioWorkflowPathsActivity.cs | 4 +- .../Audio/TranscodeDashAudioActivity.cs | 8 +- .../Audio/UpdateTrackAudioActivity.cs | 14 +-- .../Files/DownloadFileFromBucketActivity.cs | 4 +- .../Files/RemoveFileFromBucketActivity.cs | 4 +- .../Files/TransferFilesToBucketActivity.cs | 6 +- .../Files/UploadFileToBucketActivity.cs | 11 +-- .../GeneratePictureWorkflowPathsActivity.cs | 4 +- .../Pictures/ResizePictureActivity.cs | 14 ++- .../Pictures/UpdatePlayListPictureActivity.cs | 32 +++---- .../Pictures/UpdateTrackPictureActivity.cs | 32 +++---- ...20260328141805_FirstMigration.Designer.cs} | 30 +++--- ...on.cs => 20260328141805_FirstMigration.cs} | 26 ++--- .../Migrations/DatabaseModelSnapshot.cs | 28 +++--- Infrastructure/Pictures/PictureHandler.cs | 6 +- Infrastructure/Storage/StorageHandler.cs | 96 +++++++++---------- 28 files changed, 236 insertions(+), 241 deletions(-) rename Infrastructure/Persistence/Migrations/{20260325003221_FirstMigration.Designer.cs => 20260328141805_FirstMigration.Designer.cs} (93%) rename Infrastructure/Persistence/Migrations/{20260325003221_FirstMigration.cs => 20260328141805_FirstMigration.cs} (88%) diff --git a/Application/Contracts/Infrastructure/IStorageHandler.cs b/Application/Contracts/Infrastructure/IStorageHandler.cs index 3056fab..cb5d2df 100644 --- a/Application/Contracts/Infrastructure/IStorageHandler.cs +++ b/Application/Contracts/Infrastructure/IStorageHandler.cs @@ -4,19 +4,19 @@ namespace Musify.Application.Contracts.Infrastructure { public interface IStorageHandler { - Task> GetFileAsync(string bucketName, string keyName, CancellationToken cancellationToken); + Task> GetFileAsync(string bucket, string key, CancellationToken cancellationToken); - Task GetUrlAsync(string bucketName, string keyName, TimeSpan ExpirationTime, CancellationToken cancellationToken); + Task GetUrlAsync(string bucket, string key, TimeSpan ExpirationTime, CancellationToken cancellationToken); - Task> UploadFileAsync(string filePath, string bucketName, string keyName, CancellationToken cancellationToken); + Task> UploadFileAsync(string filePath, string bucket, string key, CancellationToken cancellationToken); - Task> UploadFileAsync(Stream sourceStream, string contentType, string bucketName, string keyName, CancellationToken cancellationToken); + Task> UploadFileAsync(Stream sourceStream, string contentType, string bucket, string key, CancellationToken cancellationToken); - Task TransferFilesAsync(string sourceDirectory, string bucketName, string route, CancellationToken cancellationToken); + Task TransferFilesAsync(string sourceDirectory, string bucket, string route, CancellationToken cancellationToken); - Task RemoveFileAsync(string bucketName, string keyName, CancellationToken cancellationToken); + Task RemoveFileAsync(string bucket, string key, CancellationToken cancellationToken); - Task CopyFileAsync(string sourceBucketName, string sourceKeyName, string destinationBucketName, string destinationKeyName, + Task CopyFileAsync(string sourceBucket, string sourceKey, string destinationBucket, string destinationKey, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/Application/PlayLists/Handlers/CreatePlayListCommandHandler.cs b/Application/PlayLists/Handlers/CreatePlayListCommandHandler.cs index 15282d5..1bdd67d 100644 --- a/Application/PlayLists/Handlers/CreatePlayListCommandHandler.cs +++ b/Application/PlayLists/Handlers/CreatePlayListCommandHandler.cs @@ -32,10 +32,10 @@ namespace Musify.Application.PlayLists.Handlers Name = request.Name, NormalizedName = request.Name.Trim().ToUpperInvariant(), Description = request.Description, - OriginalPictureKeyName = playListConfiguration.Routes.PresetOriginalPicture, - SmallPictureKeyName = playListConfiguration.Routes.PresetSmallPicture, - MediumPictureKeyName = playListConfiguration.Routes.PresetMediumPicture, - LargePictureKeyName = playListConfiguration.Routes.PresetLargePicture, + OriginalPictureName = playListConfiguration.Routes.PresetOriginalPicture, + SmallPictureName = playListConfiguration.Routes.PresetSmallPicture, + MediumPictureName = playListConfiguration.Routes.PresetMediumPicture, + LargePictureName = playListConfiguration.Routes.PresetLargePicture, }; var setPictureResult = request.Picture is null @@ -63,12 +63,12 @@ namespace Musify.Application.PlayLists.Handlers if (!uploadResult.IsSuccess) { - logger.LogError("Failed to upload picture for PlayList with Id={PlayListId} to storage. Storage handler returned error: {ErrorMessage}", + logger.LogError("Failed to upload picture for PlayList with Id={PlayListId} to storage. Storage handler returned error={ErrorMessage}", playList.Id, string.Join("; ", uploadResult.Errors)); return Result.Error($"Failed to upload picture for PlayList with Id {playList.Id} to storage."); } - playList.OriginalPictureKeyName = pictureName; + playList.OriginalPictureName = pictureName; logger.LogInformation("Playlist image uploaded successfully for PlayList with Id={PlayListId}.", playList.Id); try diff --git a/Application/PlayLists/Handlers/DeletePlayListCommandHandler.cs b/Application/PlayLists/Handlers/DeletePlayListCommandHandler.cs index 8f7838c..1151b5e 100644 --- a/Application/PlayLists/Handlers/DeletePlayListCommandHandler.cs +++ b/Application/PlayLists/Handlers/DeletePlayListCommandHandler.cs @@ -30,15 +30,15 @@ namespace Musify.Application.PlayLists.Handlers var keysToRemove = new List(); - if (playList.SmallPictureKeyName != playListConfiguration.Routes.PresetSmallPicture) + if (playList.SmallPictureName != playListConfiguration.Routes.PresetSmallPicture) keysToRemove.Add(Path.Combine(playListConfiguration.Routes.SmallPicturesPath, - playList.SmallPictureKeyName)); - if (playList.MediumPictureKeyName != playListConfiguration.Routes.PresetMediumPicture) + playList.SmallPictureName)); + if (playList.MediumPictureName != playListConfiguration.Routes.PresetMediumPicture) keysToRemove.Add(Path.Combine(playListConfiguration.Routes.MediumPicturesPath, - playList.MediumPictureKeyName)); - if (playList.LargePictureKeyName != playListConfiguration.Routes.PresetLargePicture) + playList.MediumPictureName)); + if (playList.LargePictureName != playListConfiguration.Routes.PresetLargePicture) keysToRemove.Add(Path.Combine(playListConfiguration.Routes.LargePicturesPath, - playList.LargePictureKeyName)); + playList.LargePictureName)); foreach (var key in keysToRemove) { @@ -48,7 +48,7 @@ namespace Musify.Application.PlayLists.Handlers { if (publishResult.IsNotFound()) { - logger.LogWarning("File with key={KeyName} not found in storage while trying to publish remove file event for PlayList with id={PlayListId}.", key, playList.Id); + logger.LogWarning("File with key={Key} not found in storage while trying to publish remove file event for PlayList with id={PlayListId}.", key, playList.Id); continue; } @@ -62,19 +62,19 @@ namespace Musify.Application.PlayLists.Handlers return Result.NoContent(); } - async Task TryPublishRemoveFileEventAsync(Guid playListId, string keyName, CancellationToken cancellationToken) + async Task TryPublishRemoveFileEventAsync(Guid playListId, string key, CancellationToken cancellationToken) { try { await eventBus.PublishAsync(new RemoveFileEvent( storageConfiguration.BucketName, - keyName), cancellationToken); + key), cancellationToken); return Result.Success(); } catch (Exception exception) { - logger.LogError(exception, "Failed to publish remove file event for PlayList id={PlayListId} and key={KeyName}.", playListId, keyName); + logger.LogError(exception, "Failed to publish remove file event for PlayList id={PlayListId} and key={Key}.", playListId, key); return Result.Error($"Failed to publish remove file event for PlayList with id {playListId}."); } } diff --git a/Application/PlayLists/Handlers/UpdatePlayListCommandHandler.cs b/Application/PlayLists/Handlers/UpdatePlayListCommandHandler.cs index 1e476f1..0647ed9 100644 --- a/Application/PlayLists/Handlers/UpdatePlayListCommandHandler.cs +++ b/Application/PlayLists/Handlers/UpdatePlayListCommandHandler.cs @@ -23,13 +23,13 @@ namespace Musify.Application.PlayLists.Handlers if (playList is null) { - logger.LogInformation("PlayList with id {PlayListId} not found", request.PlayListId); + logger.LogInformation("PlayList with id={PlayListId} not found", request.PlayListId); return Result.NotFound(); } if (playList.UserId != request.UserId) { - logger.LogWarning("User with id {UserId} is not the owner of the PlayList with id {PlayListId}", request.UserId, request.PlayListId); + logger.LogWarning("User with id={UserId} is not the owner of the PlayList with id={PlayListId}", request.UserId, request.PlayListId); return Result.Unauthorized(); } @@ -51,20 +51,20 @@ namespace Musify.Application.PlayLists.Handlers return Result.Success(PlayListResponse.FromEntity(playList)); } - if (playList.SmallPictureKeyName != playListConfiguration.Routes.PresetSmallPicture) + if (playList.SmallPictureName != playListConfiguration.Routes.PresetSmallPicture) await PublishRemoveFileEvent(Path.Combine( playListConfiguration.Routes.SmallPicturesPath, - playList.SmallPictureKeyName), + playList.SmallPictureName), cancellationToken); - if (playList.MediumPictureKeyName != playListConfiguration.Routes.PresetMediumPicture) + if (playList.MediumPictureName != playListConfiguration.Routes.PresetMediumPicture) await PublishRemoveFileEvent(Path.Combine( playListConfiguration.Routes.MediumPicturesPath, - playList.MediumPictureKeyName), + playList.MediumPictureName), cancellationToken); - if (playList.LargePictureKeyName != playListConfiguration.Routes.PresetLargePicture) + if (playList.LargePictureName != playListConfiguration.Routes.PresetLargePicture) await PublishRemoveFileEvent(Path.Combine( playListConfiguration.Routes.LargePicturesPath, - playList.LargePictureKeyName), + playList.LargePictureName), cancellationToken); var newImageId = Guid.NewGuid(); @@ -74,7 +74,7 @@ namespace Musify.Application.PlayLists.Handlers var uploadResult = await UploadFile(request.NewPicture, newImageStorageKey, cancellationToken); if (!uploadResult.IsSuccess) { - logger.LogError("Failed to upload picture for PlayList with Id={PlayListId} to storage. Storage handler returned error: {ErrorMessage}", + logger.LogError("Failed to upload picture for PlayList with Id={PlayListId} to storage. Storage handler returned error?={ErrorMessage}", playList.Id, string.Join("; ", uploadResult.Errors)); return Result.Error($"Failed to upload picture for PlayList with Id {playList.Id} to storage."); } @@ -85,14 +85,14 @@ namespace Musify.Application.PlayLists.Handlers } catch (Exception exception) { - logger.LogError(exception, "Failed to publish update picture event for PlayList with id {PlayListId}.", playList.Id); + logger.LogError(exception, "Failed to publish update picture event for PlayList with id={PlayListId}.", playList.Id); return Result.Error($"Failed to publish update picture event for PlayList with id {playList.Id}."); } database.PlayLists.Update(playList); await database.SaveChangesAsync(cancellationToken); - logger.LogInformation("Updated PlayList with id={PlayListId} and picture key {PictureKey}.", playList.Id, newImageStorageKey); + logger.LogInformation("Updated PlayList with id={PlayListId} and picture key={PictureKey}.", playList.Id, newImageStorageKey); return Result.Success(PlayListResponse.FromEntity(playList)); } @@ -110,7 +110,7 @@ namespace Musify.Application.PlayLists.Handlers } catch (Exception exception) { - logger.LogError(exception, "Failed to publish remove file event for key {Key}.", key); + logger.LogError(exception, "Failed to publish remove file event for key={Key}.", key); return Result.Error($"Failed to publish remove file event for key {key}."); } } diff --git a/Application/PlayLists/Responses/PlayListResponse.cs b/Application/PlayLists/Responses/PlayListResponse.cs index d2888fc..6ebebaf 100644 --- a/Application/PlayLists/Responses/PlayListResponse.cs +++ b/Application/PlayLists/Responses/PlayListResponse.cs @@ -18,9 +18,9 @@ namespace Musify.Application.PlayLists.Responses playList.Id, playList.Name, playList.Description, - playList.SmallPictureKeyName, - playList.MediumPictureKeyName, - playList.LargePictureKeyName, + playList.SmallPictureName, + playList.MediumPictureName, + playList.LargePictureName, playList.CreatedDate, playList.UpdatedDate); } diff --git a/Application/Tracks/Handler/CreateTrackCommandHandler.cs b/Application/Tracks/Handler/CreateTrackCommandHandler.cs index 139e967..423ff4d 100644 --- a/Application/Tracks/Handler/CreateTrackCommandHandler.cs +++ b/Application/Tracks/Handler/CreateTrackCommandHandler.cs @@ -21,7 +21,7 @@ namespace Musify.Application.Tracks.Handler if (userExists is null) { - logger.LogWarning("User with id {UserId} not found", request.UserId); + logger.LogWarning("User with id={UserId} not found", request.UserId); return Result.NotFound($"User with id {request.UserId} not found"); } @@ -31,11 +31,11 @@ namespace Musify.Application.Tracks.Handler { Title = request.Title, NormalizedTitle = request.Title.Trim().ToUpperInvariant(), - OriginalPictureKeyName = originalPictureFileName, - OriginalAudioKeyName = originalAudioFileName, - SmallPictureKeyName = trackConfiguration.Routes.PresetMediumPicture, - MediumPictureKeyName = trackConfiguration.Routes.PresetMediumPicture, - LargePictureKeyName = trackConfiguration.Routes.PresetLargePicture, + OriginalPictureName = originalPictureFileName, + OriginalAudioName = originalAudioFileName, + SmallPictureName = trackConfiguration.Routes.PresetMediumPicture, + MediumPictureName = trackConfiguration.Routes.PresetMediumPicture, + LargePictureName = trackConfiguration.Routes.PresetLargePicture, }; var originalPictureKey = Path.Combine(trackConfiguration.Routes.OriginalPicturesPath, @@ -43,7 +43,7 @@ namespace Musify.Application.Tracks.Handler var pictureUploadResult = await UploadFile(request.Picture, originalPictureKey, cancellationToken); if (!pictureUploadResult.IsSuccess) { - logger.LogError("Failed to upload picture for track {TrackTitle}", request.Title); + logger.LogError("Failed to upload picture for track={TrackTitle}", request.Title); return Result.Error($"Failed to upload picture for track {request.Title}"); } @@ -53,7 +53,7 @@ namespace Musify.Application.Tracks.Handler var audioUploadResult = await UploadFile(request.Audio, audioKey, cancellationToken); if (!audioUploadResult.IsSuccess) { - logger.LogError("Failed to upload audio for track {TrackTitle}", request.Title); + logger.LogError("Failed to upload audio for track={TrackTitle}", request.Title); return Result.Error($"Failed to upload audio for track {request.Title}"); } diff --git a/Application/Users/Handlers/CreateUserCommandHandler.cs b/Application/Users/Handlers/CreateUserCommandHandler.cs index 64ab778..a7debf7 100644 --- a/Application/Users/Handlers/CreateUserCommandHandler.cs +++ b/Application/Users/Handlers/CreateUserCommandHandler.cs @@ -14,8 +14,6 @@ namespace Musify.Application.Users.Handlers { public async Task> Handle(CreateUserCommand request, CancellationToken cancellationToken) { - logger.LogDebug("Handling {CommandName} with Id: {UserId}", nameof(CreateUserCommand), request.Id); - var existingUser = await database.Users.SingleOrDefaultAsync(u => u.Id == request.Id, cancellationToken); if (existingUser is not null) diff --git a/Domain/Entities/PlayList.cs b/Domain/Entities/PlayList.cs index 876854e..3d73d19 100644 --- a/Domain/Entities/PlayList.cs +++ b/Domain/Entities/PlayList.cs @@ -22,24 +22,24 @@ namespace Musify.Domain.Entities public required string NormalizedName { get; set; } [Required] - [MaxLength(254)] + [MaxLength(256)] public required string Description { get; set; } = "No description was provided."; [Required] [MaxLength(64)] - public required string OriginalPictureKeyName { get; set; } + public required string OriginalPictureName { get; set; } [Required] [MaxLength(64)] - public required string SmallPictureKeyName { get; set; } + public required string SmallPictureName { get; set; } [Required] [MaxLength(64)] - public required string MediumPictureKeyName { get; set; } + public required string MediumPictureName { get; set; } [Required] [MaxLength(64)] - public required string LargePictureKeyName { get; set; } + public required string LargePictureName { get; set; } [Required] public DateTime CreatedDate { get; set; } = DateTime.UtcNow; diff --git a/Domain/Entities/Track.cs b/Domain/Entities/Track.cs index ba4f802..b1f9592 100644 --- a/Domain/Entities/Track.cs +++ b/Domain/Entities/Track.cs @@ -18,26 +18,26 @@ namespace Musify.Domain.Entities [Required] [MaxLength(64)] - public required string OriginalPictureKeyName { get; set; } + public required string OriginalPictureName { get; set; } [Required] [MaxLength(64)] - public required string SmallPictureKeyName { get; set; } + public required string SmallPictureName { get; set; } [Required] [MaxLength(64)] - public required string MediumPictureKeyName { get; set; } + public required string MediumPictureName { get; set; } [Required] [MaxLength(64)] - public required string LargePictureKeyName { get; set; } + public required string LargePictureName { get; set; } [Required] [MaxLength(64)] - public required string OriginalAudioKeyName { get; set; } + public required string OriginalAudioName { get; set; } [MaxLength(64)] - public string AudioFolderKeyName { get; set; } = string.Empty; + public string AudioFolderName { get; set; } = string.Empty; [Required] public DateTime CreatedDate { get; set; } = DateTime.UtcNow; diff --git a/Domain/Entities/Upload.cs b/Domain/Entities/Upload.cs index a74db25..9e8c42b 100644 --- a/Domain/Entities/Upload.cs +++ b/Domain/Entities/Upload.cs @@ -10,10 +10,10 @@ namespace Musify.Domain.Entities public Guid Id { get; set; } = Guid.NewGuid(); [Required] - public required string KeyName { get; set; } + public required string Bucket { get; set; } [Required] - public required string BucketName { get; set; } + public required string Key { get; set; } [Required] public required string ContentType { get; set; } diff --git a/Infrastructure/Audio/AudioTranscoder.cs b/Infrastructure/Audio/AudioTranscoder.cs index 140c88b..cfe5212 100644 --- a/Infrastructure/Audio/AudioTranscoder.cs +++ b/Infrastructure/Audio/AudioTranscoder.cs @@ -18,7 +18,7 @@ namespace Musify.Infrastructure.Audio Directory.CreateDirectory(destinationPath); logger.LogInformation( - "Starting audio transcoding to DASH. DestinationPath: {DestinationPath}, Timeout: {Timeout}, Executable: {Executable}", + "Starting audio transcoding to DASH. DestinationPath={DestinationPath}, Timeout={Timeout}, Executable={Executable}", destinationPath, audioTranscoderConfiguration.TranscodingTimeout, audioTranscoderConfiguration.Ffmpeg.ExecutableName); @@ -33,24 +33,24 @@ namespace Musify.Infrastructure.Audio if (executionResult.ExitCode != 0) { logger.LogError( - "Audio transcoding to DASH format failed with exit code {ExitCode}. Standard Output: {StandardOutput}, Standard Error: {StandardError}", + "Audio transcoding to DASH format failed with exit code={ExitCode}. Standard Output={StandardOutput}, Standard Error={StandardError}", executionResult.ExitCode, executionResult.StandardOutput, executionResult.StandardError); - return Result.Error($"Audio transcoding failed with exit code {executionResult.ExitCode}. See logs for details."); + return Result.Error($"Audio transcoding failed with exit code: {executionResult.ExitCode}. See logs for details."); } - logger.LogInformation("Audio transcoding to DASH format completed successfully. DestinationPath: {DestinationPath}", destinationPath); + logger.LogInformation("Audio transcoding to DASH format completed successfully. DestinationPath={DestinationPath}", destinationPath); return Result.Success(); } catch (TimeoutException timeoutException) { - logger.LogError(timeoutException, "Audio transcoding timed out after {Timeout}. DestinationPath: {DestinationPath}", audioTranscoderConfiguration.TranscodingTimeout, destinationPath); + logger.LogError(timeoutException, "Audio transcoding timed out after={Timeout}. DestinationPath={DestinationPath}", audioTranscoderConfiguration.TranscodingTimeout, destinationPath); return Result.Error("Audio transcoding timed out."); } catch (Exception exception) { - logger.LogError(exception, "An error occurred while transcoding audio to DASH format. DestinationPath: {DestinationPath}", destinationPath); + logger.LogError(exception, "An error occurred while transcoding audio to DASH format. DestinationPath={DestinationPath}", destinationPath); return Result.Error(exception.Message); } } @@ -59,13 +59,13 @@ namespace Musify.Infrastructure.Audio { if (!File.Exists(filePath)) { - logger.LogWarning("Audio validation requested for a non-existing file. FilePath: {FilePath}", filePath); + logger.LogWarning("Audio validation requested for a non-existing file. FilePath={FilePath}", filePath); return Result.Error($"Audio file not found: {filePath}"); } try { - logger.LogInformation("Starting audio file validation. FilePath: {FilePath}, Timeout: {Timeout}", filePath, audioTranscoderConfiguration.TranscodingTimeout); + logger.LogInformation("Starting audio file validation. FilePath={FilePath}, Timeout={Timeout}", filePath, audioTranscoderConfiguration.TranscodingTimeout); var executionResult = await ExecuteFfmpegAsync( BuildValidateAudioArguments(filePath), @@ -77,25 +77,25 @@ namespace Musify.Infrastructure.Audio if (!isValid) { logger.LogWarning( - "Audio validation failed for file {FilePath}. Standard Error: {StandardError}", + "Audio validation failed for file={FilePath}. Standard Error={StandardError}", filePath, executionResult.StandardError); } else { - logger.LogInformation("Audio validation completed successfully. FilePath: {FilePath}", filePath); + logger.LogInformation("Audio validation completed successfully. FilePath={FilePath}", filePath); } return Result.Success(isValid); } catch (TimeoutException timeoutException) { - logger.LogError(timeoutException, "Audio validation timed out after {Timeout} for file {FilePath}.", audioTranscoderConfiguration.TranscodingTimeout, filePath); + logger.LogError(timeoutException, "Audio validation timed out after={Timeout} for file={FilePath}.", audioTranscoderConfiguration.TranscodingTimeout, filePath); return Result.Error("Audio validation timed out."); } catch (Exception exception) { - logger.LogError(exception, "An error occurred while validating audio file {FilePath}.", filePath); + logger.LogError(exception, "An error occurred while validating audio file={FilePath}.", filePath); return Result.Error(exception.Message); } } @@ -110,7 +110,7 @@ namespace Musify.Infrastructure.Audio using var process = BuildProcess(arguments, workingDirectory, redirectStandardInput: true); process.Start(); - logger.LogDebug("[{Operation}] ffmpeg process started. ProcessId: {ProcessId}, WorkingDirectory: {WorkingDirectory}", operationName, process.Id, workingDirectory); + logger.LogDebug("[{Operation}] ffmpeg process started. ProcessId={ProcessId}, WorkingDirectory={WorkingDirectory}", operationName, process.Id, workingDirectory); if (inputStream.CanSeek) inputStream.Position = 0; @@ -130,7 +130,7 @@ namespace Musify.Infrastructure.Audio using var process = BuildProcess(arguments, workingDirectory, redirectStandardInput: false); process.Start(); - logger.LogDebug("[{Operation}] ffmpeg process started. ProcessId: {ProcessId}, WorkingDirectory: {WorkingDirectory}", operationName, process.Id, workingDirectory); + logger.LogDebug("[{Operation}] ffmpeg process started. ProcessId={ProcessId}, WorkingDirectory={WorkingDirectory}", operationName, process.Id, workingDirectory); return await WaitForProcessResultAsync(process, operationName, cancellationToken); } @@ -169,7 +169,7 @@ namespace Musify.Infrastructure.Audio catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested) { logger.LogError( - "[{Operation}] ffmpeg timed out after {Timeout}. ProcessId: {ProcessId}", + "[{Operation}] ffmpeg timed out after={Timeout}. ProcessId={ProcessId}", operationName, audioTranscoderConfiguration.TranscodingTimeout, process.Id); @@ -182,7 +182,7 @@ namespace Musify.Infrastructure.Audio var standardOutput = await outputTask; logger.LogDebug( - "[{Operation}] ffmpeg finished. ProcessId: {ProcessId}, ExitCode: {ExitCode}, StdOutLength: {StdOutLength}, StdErrLength: {StdErrLength}", + "[{Operation}] ffmpeg finished. ProcessId={ProcessId}, ExitCode={ExitCode}, StdOutLength={StdOutLength}, StdErrLength={StdErrLength}", operationName, process.Id, process.ExitCode, @@ -201,7 +201,7 @@ namespace Musify.Infrastructure.Audio } catch (Exception exception) { - logger.LogError(exception, "Failed to kill ffmpeg process. ProcessId: {ProcessId}", process.Id); + logger.LogError(exception, "Failed to kill ffmpeg process. ProcessId={ProcessId}", process.Id); } } diff --git a/Infrastructure/Identity/KeycloakUserService.cs b/Infrastructure/Identity/KeycloakUserService.cs index 16ea1fa..e725d1e 100644 --- a/Infrastructure/Identity/KeycloakUserService.cs +++ b/Infrastructure/Identity/KeycloakUserService.cs @@ -23,12 +23,12 @@ namespace Musify.Infrastructure.Identity } catch (OperationCanceledException) { - logger.LogError("Operation to retrieve Keycloak user with id {KeycloakId} was cancelled.", keycloakId); + logger.LogError("Operation to retrieve Keycloak user with id={KeycloakId} was cancelled.", keycloakId); return Result.Error("Operation was cancelled."); } catch (Exception exception) { - logger.LogWarning(exception, "Keycloak user with id {KeycloakId} could not be retrieved.", keycloakId); + logger.LogWarning(exception, "Keycloak user with id={KeycloakId} could not be retrieved.", keycloakId); return Result.NotFound(); } return Result.Success(KeycloakUserMapper.Map(keycloakUser)); diff --git a/Infrastructure/MassTransit/Activities/Audio/GenerateAudioWorkflowPathsActivity.cs b/Infrastructure/MassTransit/Activities/Audio/GenerateAudioWorkflowPathsActivity.cs index 8699be2..a006bfd 100644 --- a/Infrastructure/MassTransit/Activities/Audio/GenerateAudioWorkflowPathsActivity.cs +++ b/Infrastructure/MassTransit/Activities/Audio/GenerateAudioWorkflowPathsActivity.cs @@ -38,7 +38,7 @@ namespace Musify.Infrastructure.MassTransit.Activities Directory.CreateDirectory(workingDirectory); - logger.LogDebug("Generated audio workflow paths. WorkingDirectory: {WorkingDirectory}, SourceFilePath: {SourceFilePath}", + logger.LogDebug("Generated audio workflow paths. WorkingDirectory={WorkingDirectory}, SourceFilePath={SourceFilePath}", workingDirectory, sourceFilePath); @@ -53,7 +53,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error generating audio workflow paths for key {SourceKeyName}", + logger.LogError(exception, "Error generating audio workflow paths for key={SourceKey}", executeContext.Arguments.SourceKey); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); throw; diff --git a/Infrastructure/MassTransit/Activities/Audio/TranscodeDashAudioActivity.cs b/Infrastructure/MassTransit/Activities/Audio/TranscodeDashAudioActivity.cs index c7f60cb..9629e4b 100644 --- a/Infrastructure/MassTransit/Activities/Audio/TranscodeDashAudioActivity.cs +++ b/Infrastructure/MassTransit/Activities/Audio/TranscodeDashAudioActivity.cs @@ -48,7 +48,7 @@ namespace Musify.Infrastructure.MassTransit.Activities if (!result.IsSuccess) { var errorMessage = string.Join("; ", result.Errors); - logger.LogError("Transcoding failed for file {SourceFilePath}. Errors: {ErrorMessage}", + logger.LogError("Transcoding failed for file={SourceFilePath}. Errors={ErrorMessage}", sourceFilePath, errorMessage); throw new Exception(errorMessage); } @@ -60,7 +60,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error during transcoding activity for file {SourceFilePath}", + logger.LogError(exception, "Error during transcoding activity for file={SourceFilePath}", sourceFilePath); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); throw; @@ -74,13 +74,13 @@ namespace Musify.Infrastructure.MassTransit.Activities if (Directory.Exists(compensateContext.Log.WorkingDirectory)) Directory.Delete(compensateContext.Log.WorkingDirectory, recursive: true); else - logger.LogWarning("Working directory {WorkingDirectory} does not exist during compensation", + logger.LogWarning("Working directory={WorkingDirectory} does not exist during compensation", compensateContext.Log.WorkingDirectory); return Task.FromResult(compensateContext.Compensated()); } catch (Exception exception) { - logger.LogError(exception, "Error compensating transcoded audio directory {WorkingDirectory}", compensateContext.Log.WorkingDirectory); + logger.LogError(exception, "Error compensating transcoded audio directory={WorkingDirectory}", compensateContext.Log.WorkingDirectory); return Task.FromResult(compensateContext.Failed(exception)); } } diff --git a/Infrastructure/MassTransit/Activities/Audio/UpdateTrackAudioActivity.cs b/Infrastructure/MassTransit/Activities/Audio/UpdateTrackAudioActivity.cs index 37ea040..9381b48 100644 --- a/Infrastructure/MassTransit/Activities/Audio/UpdateTrackAudioActivity.cs +++ b/Infrastructure/MassTransit/Activities/Audio/UpdateTrackAudioActivity.cs @@ -39,21 +39,21 @@ namespace Musify.Infrastructure.MassTransit.Activities.Audio if (track is null) { - logger.LogWarning("Track with id {TrackId} not found", + logger.LogWarning("Track with id={TrackId} not found", executeContext.Arguments.TrackId); throw new InvalidOperationException($"Track with id {executeContext.Arguments.TrackId} not found"); } var log = new UpdateTrackAudioLog( track.Id, - track.AudioFolderKeyName); + track.AudioFolderName); - track.AudioFolderKeyName = Path.GetFileName(executeContext.Arguments.AudioFolderKey); + track.AudioFolderName = Path.GetFileName(executeContext.Arguments.AudioFolderKey); database.Tracks.Update(track); await database.SaveChangesAsync(executeContext.CancellationToken); - logger.LogInformation("Updated Track {TrackId} audio", + logger.LogInformation("Updated Track={TrackId} audio", executeContext.Arguments.TrackId); await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken); @@ -61,7 +61,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Audio } catch (Exception exception) { - logger.LogError(exception, "Error updating Track {TrackId} audio", + logger.LogError(exception, "Error updating Track={TrackId} audio", executeContext.Arguments.TrackId); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); throw; @@ -81,7 +81,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Audio return compensateContext.Compensated(); } - track.AudioFolderKeyName = compensateContext.Log.PreviousFolderAudioKey; + track.AudioFolderName = compensateContext.Log.PreviousFolderAudioKey; database.Tracks.Update(track); await database.SaveChangesAsync(compensateContext.CancellationToken); @@ -90,7 +90,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Audio } catch (Exception exception) { - logger.LogError(exception, "Error compensating Track {TrackId} audio", compensateContext.Log.TrackId); + logger.LogError(exception, "Error compensating Track={TrackId} audio", compensateContext.Log.TrackId); return compensateContext.Failed(exception); } } diff --git a/Infrastructure/MassTransit/Activities/Files/DownloadFileFromBucketActivity.cs b/Infrastructure/MassTransit/Activities/Files/DownloadFileFromBucketActivity.cs index 61e8ec5..62172f4 100644 --- a/Infrastructure/MassTransit/Activities/Files/DownloadFileFromBucketActivity.cs +++ b/Infrastructure/MassTransit/Activities/Files/DownloadFileFromBucketActivity.cs @@ -44,7 +44,7 @@ namespace Musify.Infrastructure.MassTransit.Activities if (!getFile.IsSuccess) { var errorMessage = string.Join("; ", getFile.Errors); - logger.LogWarning("Failed to download file from bucket. Bucket: {BucketName}, Key: {KeyName}, Errors: {Errors}", + logger.LogWarning("Failed to download file from bucket. Bucket={Bucket}, Key={Key}, Errors={Errors}", executeContext.Arguments.Bucket, executeContext.Arguments.Key, errorMessage); @@ -85,7 +85,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error compensating downloaded file {DestinationFilePath}", compensateContext.Log.DestinationFilePath); + logger.LogError(exception, "Error compensating downloaded file={DestinationFilePath}", compensateContext.Log.DestinationFilePath); return Task.FromResult(compensateContext.Failed(exception)); } } diff --git a/Infrastructure/MassTransit/Activities/Files/RemoveFileFromBucketActivity.cs b/Infrastructure/MassTransit/Activities/Files/RemoveFileFromBucketActivity.cs index 73ef143..6d889b5 100644 --- a/Infrastructure/MassTransit/Activities/Files/RemoveFileFromBucketActivity.cs +++ b/Infrastructure/MassTransit/Activities/Files/RemoveFileFromBucketActivity.cs @@ -40,7 +40,7 @@ namespace Musify.Infrastructure.MassTransit.Activities if (!removeFile.IsSuccess) { var errorMessage = string.Join("; ", removeFile.Errors); - logger.LogWarning("Failed to remove file {KeyName} from bucket {BucketName}. Errors: {Errors}", + logger.LogWarning("Failed to remove file={Key} from bucket={Bucket}. Errors={Errors}", executeContext.Arguments.Key, executeContext.Arguments.Bucket, errorMessage); @@ -51,7 +51,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error removing file {KeyName} from bucket {BucketName}", + logger.LogError(exception, "Error removing file={Key} from bucket={Bucket}", executeContext.Arguments.Key, executeContext.Arguments.Bucket); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); diff --git a/Infrastructure/MassTransit/Activities/Files/TransferFilesToBucketActivity.cs b/Infrastructure/MassTransit/Activities/Files/TransferFilesToBucketActivity.cs index 645c948..c3500c7 100644 --- a/Infrastructure/MassTransit/Activities/Files/TransferFilesToBucketActivity.cs +++ b/Infrastructure/MassTransit/Activities/Files/TransferFilesToBucketActivity.cs @@ -51,7 +51,7 @@ namespace Musify.Infrastructure.MassTransit.Activities if (!transferFilesResult.IsSuccess) { var errorMessage = string.Join("; ", transferFilesResult.Errors); - logger.LogWarning("Failed to transfer files from {FolderPath} to bucket {DestinationBucketName}, key {DestinationKeyName}. Errors: {Errors}", + logger.LogWarning("Failed to transfer files from={FolderPath} to bucket={DestinationBucket}, key={DestinationKey}. Errors={Errors}", folderPath, executeContext.Arguments.DestinationBucket, destinationKey, @@ -64,7 +64,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error transferring files from {FolderPath} to bucket {DestinationBucketName}", + logger.LogError(exception, "Error transferring files from={FolderPath} to bucket={DestinationBucket}", folderPath, executeContext.Arguments.DestinationBucket); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); @@ -88,7 +88,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error compensating transferred files to bucket {DestinationBucketName}", compensateContext.Log.DestinationBucket); + logger.LogError(exception, "Error compensating transferred files to bucket={DestinationBucket}", compensateContext.Log.DestinationBucket); return compensateContext.Failed(exception); } } diff --git a/Infrastructure/MassTransit/Activities/Files/UploadFileToBucketActivity.cs b/Infrastructure/MassTransit/Activities/Files/UploadFileToBucketActivity.cs index d7d225b..60585c4 100644 --- a/Infrastructure/MassTransit/Activities/Files/UploadFileToBucketActivity.cs +++ b/Infrastructure/MassTransit/Activities/Files/UploadFileToBucketActivity.cs @@ -46,7 +46,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files if (!uploadResult.IsSuccess) { var errors = string.Join("; ", uploadResult.Errors); - logger.LogWarning("Failed to upload file to bucket. Bucket: {BucketName}, Key: {KeyName}, Errors: {Errors}", + logger.LogWarning("Failed to upload file to bucket. Bucket={Bucket}, Key={Key}, Errors={Errors}", executeContext.Arguments.DestinationBucket, executeContext.Arguments.DestinationRoute, errors); @@ -60,7 +60,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files } catch (Exception exception) { - logger.LogError(exception, "An error occurred while uploading file to bucket for process {ProcessId} at step {StepId}", processId, stepId); + logger.LogError(exception, "An error occurred while uploading file to bucket for process={ProcessId} at step={StepId}", processId, stepId); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); throw; } @@ -78,16 +78,15 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files if (!uploadResult.IsSuccess) { var errors = string.Join("; ", uploadResult.Errors); - var errorMessage = $"Failed to remove file from bucket during compensation. Bucket: {compensateContext.Log.DestinationBucket}, Key: {compensateContext.Log.DestinationKey}, Errors: {errors}"; + logger.LogError($"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)); + 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) { - logger.LogError(exception, "An error occurred while compensating upload file to bucket activity for bucket {BucketName} and key {KeyName}", + logger.LogError(exception, "An error occurred while compensating upload file to bucket activity for bucket={Bucket} and key={Key}", compensateContext.Log.DestinationBucket, compensateContext.Log.DestinationKey); return compensateContext.Failed(exception); diff --git a/Infrastructure/MassTransit/Activities/Pictures/GeneratePictureWorkflowPathsActivity.cs b/Infrastructure/MassTransit/Activities/Pictures/GeneratePictureWorkflowPathsActivity.cs index 867a83a..f34a7bd 100644 --- a/Infrastructure/MassTransit/Activities/Pictures/GeneratePictureWorkflowPathsActivity.cs +++ b/Infrastructure/MassTransit/Activities/Pictures/GeneratePictureWorkflowPathsActivity.cs @@ -47,7 +47,7 @@ namespace Musify.Infrastructure.MassTransit.Activities Directory.CreateDirectory(workingDirectory); - logger.LogDebug("Generated picture workflow paths. WorkingDirectory: {WorkingDirectory}, SourceFilePath: {SourceFilePath}", + logger.LogDebug("Generated picture workflow paths. WorkingDirectory={WorkingDirectory}, SourceFilePath={SourceFilePath}", workingDirectory, sourceFilePath); @@ -64,7 +64,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error generating picture workflow paths for key {SourceKeyName}", + logger.LogError(exception, "Error generating picture workflow paths for key={SourceKey}", executeContext.Arguments.SourceKey); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); throw; diff --git a/Infrastructure/MassTransit/Activities/Pictures/ResizePictureActivity.cs b/Infrastructure/MassTransit/Activities/Pictures/ResizePictureActivity.cs index eea6a1f..4768713 100644 --- a/Infrastructure/MassTransit/Activities/Pictures/ResizePictureActivity.cs +++ b/Infrastructure/MassTransit/Activities/Pictures/ResizePictureActivity.cs @@ -41,7 +41,7 @@ namespace Musify.Infrastructure.MassTransit.Activities { if (!File.Exists(sourceFilePath)) { - logger.LogWarning("Source file not found at {SourceFilePath}", sourceFilePath); + logger.LogWarning("Source file not found at={SourceFilePath}", sourceFilePath); throw new FileNotFoundException($"Source file not found: {sourceFilePath}"); } @@ -56,7 +56,7 @@ namespace Musify.Infrastructure.MassTransit.Activities if (!resizedPicture.IsSuccess) { var errorMessage = string.Join("; ", resizedPicture.Errors); - logger.LogError("Failed to resize picture {SourceFilePath} to {Width}x{Height}. Errors: {Errors}", + logger.LogError("Failed to resize picture={SourceFilePath} to={Width}x{Height}. Errors={Errors}", sourceFilePath, executeContext.Arguments.Width, executeContext.Arguments.Height, @@ -71,18 +71,16 @@ namespace Musify.Infrastructure.MassTransit.Activities await using var destinationStream = File.Create(destinationFilePath); await resizedPicture.Value.CopyToAsync(destinationStream, executeContext.CancellationToken); - logger.LogDebug("Picture resized from {SourceFilePath} to {DestinationFilePath} ({Width}x{Height})", + logger.LogDebug("Picture resized from={SourceFilePath} to={DestinationFilePath}", sourceFilePath, - destinationFilePath, - executeContext.Arguments.Width, - executeContext.Arguments.Height); + destinationFilePath); await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken); return executeContext.Completed(new ResizePictureLog(destinationFilePath)); } catch (Exception exception) { - logger.LogError(exception, "Error resizing picture {SourceFilePath}", sourceFilePath); + logger.LogError(exception, "Error resizing picture={SourceFilePath}", sourceFilePath); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); throw; } @@ -97,7 +95,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error compensating resized file {DestinationFilePath}", compensateContext.Log.DestinationFilePath); + logger.LogError(exception, "Error compensating resized file={DestinationFilePath}", compensateContext.Log.DestinationFilePath); return Task.FromResult(compensateContext.Failed(exception)); } } diff --git a/Infrastructure/MassTransit/Activities/Pictures/UpdatePlayListPictureActivity.cs b/Infrastructure/MassTransit/Activities/Pictures/UpdatePlayListPictureActivity.cs index 992bd5a..2901432 100644 --- a/Infrastructure/MassTransit/Activities/Pictures/UpdatePlayListPictureActivity.cs +++ b/Infrastructure/MassTransit/Activities/Pictures/UpdatePlayListPictureActivity.cs @@ -46,27 +46,27 @@ namespace Musify.Infrastructure.MassTransit.Activities if (playList is null) { - logger.LogWarning("PlayList with id {PlayListId} not found", + logger.LogWarning("PlayList with id={PlayListId} not found", executeContext.Arguments.PlayListId); throw new InvalidOperationException($"PlayList with id {executeContext.Arguments.PlayListId} not found"); } var log = new UpdatePlayListPictureLog( playList.Id, - playList.OriginalPictureKeyName, - playList.SmallPictureKeyName, - playList.MediumPictureKeyName, - playList.LargePictureKeyName); + playList.OriginalPictureName, + playList.SmallPictureName, + playList.MediumPictureName, + playList.LargePictureName); - playList.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKey); - playList.SmallPictureKeyName = Path.GetFileName(smallResizedVariable); - playList.MediumPictureKeyName = Path.GetFileName(mediumResizedVariable); - playList.LargePictureKeyName = Path.GetFileName(largeResizedVariable); + playList.OriginalPictureName = Path.GetFileName(executeContext.Arguments.OriginalPictureKey); + playList.SmallPictureName = Path.GetFileName(smallResizedVariable); + playList.MediumPictureName = Path.GetFileName(mediumResizedVariable); + playList.LargePictureName = Path.GetFileName(largeResizedVariable); database.PlayLists.Update(playList); await database.SaveChangesAsync(executeContext.CancellationToken); - logger.LogInformation("Updated PlayList {PlayListId} pictures", + logger.LogInformation("Updated PlayList={PlayListId} pictures", executeContext.Arguments.PlayListId); await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken); @@ -74,7 +74,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error updating PlayList {PlayListId} pictures", + logger.LogError(exception, "Error updating PlayList={PlayListId} pictures", executeContext.Arguments.PlayListId); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); throw; @@ -94,10 +94,10 @@ namespace Musify.Infrastructure.MassTransit.Activities return compensateContext.Compensated(); } - playList.OriginalPictureKeyName = compensateContext.Log.PreviousOriginalPictureKey; - playList.SmallPictureKeyName = compensateContext.Log.PreviousSmallPictureKey; - playList.MediumPictureKeyName = compensateContext.Log.PreviousMediumPictureKey; - playList.LargePictureKeyName = compensateContext.Log.PreviousLargePictureKey; + playList.OriginalPictureName = compensateContext.Log.PreviousOriginalPictureKey; + playList.SmallPictureName = compensateContext.Log.PreviousSmallPictureKey; + playList.MediumPictureName = compensateContext.Log.PreviousMediumPictureKey; + playList.LargePictureName = compensateContext.Log.PreviousLargePictureKey; database.PlayLists.Update(playList); await database.SaveChangesAsync(compensateContext.CancellationToken); @@ -106,7 +106,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error compensating PlayList {PlayListId} pictures", compensateContext.Log.PlayListId); + logger.LogError(exception, "Error compensating PlayList={PlayListId} pictures", compensateContext.Log.PlayListId); return compensateContext.Failed(exception); } } diff --git a/Infrastructure/MassTransit/Activities/Pictures/UpdateTrackPictureActivity.cs b/Infrastructure/MassTransit/Activities/Pictures/UpdateTrackPictureActivity.cs index fd68ed7..0ec8e1a 100644 --- a/Infrastructure/MassTransit/Activities/Pictures/UpdateTrackPictureActivity.cs +++ b/Infrastructure/MassTransit/Activities/Pictures/UpdateTrackPictureActivity.cs @@ -46,27 +46,27 @@ namespace Musify.Infrastructure.MassTransit.Activities if (track is null) { - logger.LogWarning("Track with id {TrackId} not found", + logger.LogWarning("Track with id={TrackId} not found", executeContext.Arguments.TrackId); throw new InvalidOperationException($"Track with id {executeContext.Arguments.TrackId} not found"); } var log = new UpdateTrackPictureLog( track.Id, - track.OriginalPictureKeyName, - track.SmallPictureKeyName, - track.MediumPictureKeyName, - track.LargePictureKeyName); + track.OriginalPictureName, + track.SmallPictureName, + track.MediumPictureName, + track.LargePictureName); - track.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKey); - track.SmallPictureKeyName = Path.GetFileName(smallResizedVariable); - track.MediumPictureKeyName = Path.GetFileName(mediumResizedVariable); - track.LargePictureKeyName = Path.GetFileName(largeResizedVariable); + track.OriginalPictureName = Path.GetFileName(executeContext.Arguments.OriginalPictureKey); + track.SmallPictureName = Path.GetFileName(smallResizedVariable); + track.MediumPictureName = Path.GetFileName(mediumResizedVariable); + track.LargePictureName = Path.GetFileName(largeResizedVariable); database.Tracks.Update(track); await database.SaveChangesAsync(executeContext.CancellationToken); - logger.LogInformation("Updated Track {TrackId} pictures", + logger.LogInformation("Updated Track={TrackId} pictures", executeContext.Arguments.TrackId); await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken); @@ -74,7 +74,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error updating Track {TrackId} pictures", + logger.LogError(exception, "Error updating Track={TrackId} pictures", executeContext.Arguments.TrackId); await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken); throw; @@ -94,10 +94,10 @@ namespace Musify.Infrastructure.MassTransit.Activities return compensateContext.Compensated(); } - track.OriginalPictureKeyName = compensateContext.Log.PreviousOriginalPictureKey; - track.SmallPictureKeyName = compensateContext.Log.PreviousSmallPictureKey; - track.MediumPictureKeyName = compensateContext.Log.PreviousMediumPictureKey; - track.LargePictureKeyName = compensateContext.Log.PreviousLargePictureKey; + track.OriginalPictureName = compensateContext.Log.PreviousOriginalPictureKey; + track.SmallPictureName = compensateContext.Log.PreviousSmallPictureKey; + track.MediumPictureName = compensateContext.Log.PreviousMediumPictureKey; + track.LargePictureName = compensateContext.Log.PreviousLargePictureKey; database.Tracks.Update(track); await database.SaveChangesAsync(compensateContext.CancellationToken); @@ -106,7 +106,7 @@ namespace Musify.Infrastructure.MassTransit.Activities } catch (Exception exception) { - logger.LogError(exception, "Error compensating Track {TrackId} pictures", compensateContext.Log.TrackId); + logger.LogError(exception, "Error compensating Track={TrackId} pictures", compensateContext.Log.TrackId); return compensateContext.Failed(exception); } } diff --git a/Infrastructure/Persistence/Migrations/20260325003221_FirstMigration.Designer.cs b/Infrastructure/Persistence/Migrations/20260328141805_FirstMigration.Designer.cs similarity index 93% rename from Infrastructure/Persistence/Migrations/20260325003221_FirstMigration.Designer.cs rename to Infrastructure/Persistence/Migrations/20260328141805_FirstMigration.Designer.cs index e9a6cc7..f84d009 100644 --- a/Infrastructure/Persistence/Migrations/20260325003221_FirstMigration.Designer.cs +++ b/Infrastructure/Persistence/Migrations/20260328141805_FirstMigration.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Musify.Infrastructure.Persistence.Migrations { [DbContext(typeof(Database))] - [Migration("20260325003221_FirstMigration")] + [Migration("20260328141805_FirstMigration")] partial class FirstMigration { /// @@ -36,15 +36,15 @@ namespace Musify.Infrastructure.Persistence.Migrations b.Property("Description") .IsRequired() - .HasMaxLength(254) - .HasColumnType("character varying(254)"); + .HasMaxLength(256) + .HasColumnType("character varying(256)"); - b.Property("LargePictureKeyName") + b.Property("LargePictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("MediumPictureKeyName") + b.Property("MediumPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -59,12 +59,12 @@ namespace Musify.Infrastructure.Persistence.Migrations .HasMaxLength(50) .HasColumnType("character varying(50)"); - b.Property("OriginalPictureKeyName") + b.Property("OriginalPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("SmallPictureKeyName") + b.Property("SmallPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -195,7 +195,7 @@ namespace Musify.Infrastructure.Persistence.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("AudioFolderKeyName") + b.Property("AudioFolderName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -203,12 +203,12 @@ namespace Musify.Infrastructure.Persistence.Migrations b.Property("CreatedDate") .HasColumnType("timestamp with time zone"); - b.Property("LargePictureKeyName") + b.Property("LargePictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("MediumPictureKeyName") + b.Property("MediumPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -218,17 +218,17 @@ namespace Musify.Infrastructure.Persistence.Migrations .HasMaxLength(50) .HasColumnType("character varying(50)"); - b.Property("OriginalAudioKeyName") + b.Property("OriginalAudioName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("OriginalPictureKeyName") + b.Property("OriginalPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("SmallPictureKeyName") + b.Property("SmallPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -252,7 +252,7 @@ namespace Musify.Infrastructure.Persistence.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("BucketName") + b.Property("Bucket") .IsRequired() .HasColumnType("text"); @@ -263,7 +263,7 @@ namespace Musify.Infrastructure.Persistence.Migrations b.Property("CreatedTime") .HasColumnType("timestamp with time zone"); - b.Property("KeyName") + b.Property("Key") .IsRequired() .HasColumnType("text"); diff --git a/Infrastructure/Persistence/Migrations/20260325003221_FirstMigration.cs b/Infrastructure/Persistence/Migrations/20260328141805_FirstMigration.cs similarity index 88% rename from Infrastructure/Persistence/Migrations/20260325003221_FirstMigration.cs rename to Infrastructure/Persistence/Migrations/20260328141805_FirstMigration.cs index 5994892..d184dd8 100644 --- a/Infrastructure/Persistence/Migrations/20260325003221_FirstMigration.cs +++ b/Infrastructure/Persistence/Migrations/20260328141805_FirstMigration.cs @@ -37,12 +37,12 @@ namespace Musify.Infrastructure.Persistence.Migrations Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), NormalizedTitle = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - OriginalPictureKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - SmallPictureKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - MediumPictureKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - LargePictureKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - OriginalAudioKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - AudioFolderKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + OriginalPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + SmallPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + MediumPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + LargePictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + OriginalAudioName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + AudioFolderName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), CreatedDate = table.Column(type: "timestamp with time zone", nullable: false), UpdatedDate = table.Column(type: "timestamp with time zone", nullable: false) }, @@ -56,8 +56,8 @@ namespace Musify.Infrastructure.Persistence.Migrations columns: table => new { Id = table.Column(type: "uuid", nullable: false), - KeyName = table.Column(type: "text", nullable: false), - BucketName = table.Column(type: "text", nullable: false), + Bucket = table.Column(type: "text", nullable: false), + Key = table.Column(type: "text", nullable: false), ContentType = table.Column(type: "text", nullable: false), CreatedTime = table.Column(type: "timestamp with time zone", nullable: false), State = table.Column(type: "integer", nullable: false) @@ -113,11 +113,11 @@ namespace Musify.Infrastructure.Persistence.Migrations UserId = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), NormalizedName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - Description = table.Column(type: "character varying(254)", maxLength: 254, nullable: false), - OriginalPictureKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - SmallPictureKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - MediumPictureKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - LargePictureKeyName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + Description = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + OriginalPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + SmallPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + MediumPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + LargePictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), CreatedDate = table.Column(type: "timestamp with time zone", nullable: false), UpdatedDate = table.Column(type: "timestamp with time zone", nullable: false) }, diff --git a/Infrastructure/Persistence/Migrations/DatabaseModelSnapshot.cs b/Infrastructure/Persistence/Migrations/DatabaseModelSnapshot.cs index b4994a4..85d9421 100644 --- a/Infrastructure/Persistence/Migrations/DatabaseModelSnapshot.cs +++ b/Infrastructure/Persistence/Migrations/DatabaseModelSnapshot.cs @@ -33,15 +33,15 @@ namespace Musify.Infrastructure.Persistence.Migrations b.Property("Description") .IsRequired() - .HasMaxLength(254) - .HasColumnType("character varying(254)"); + .HasMaxLength(256) + .HasColumnType("character varying(256)"); - b.Property("LargePictureKeyName") + b.Property("LargePictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("MediumPictureKeyName") + b.Property("MediumPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -56,12 +56,12 @@ namespace Musify.Infrastructure.Persistence.Migrations .HasMaxLength(50) .HasColumnType("character varying(50)"); - b.Property("OriginalPictureKeyName") + b.Property("OriginalPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("SmallPictureKeyName") + b.Property("SmallPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -192,7 +192,7 @@ namespace Musify.Infrastructure.Persistence.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("AudioFolderKeyName") + b.Property("AudioFolderName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -200,12 +200,12 @@ namespace Musify.Infrastructure.Persistence.Migrations b.Property("CreatedDate") .HasColumnType("timestamp with time zone"); - b.Property("LargePictureKeyName") + b.Property("LargePictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("MediumPictureKeyName") + b.Property("MediumPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -215,17 +215,17 @@ namespace Musify.Infrastructure.Persistence.Migrations .HasMaxLength(50) .HasColumnType("character varying(50)"); - b.Property("OriginalAudioKeyName") + b.Property("OriginalAudioName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("OriginalPictureKeyName") + b.Property("OriginalPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("SmallPictureKeyName") + b.Property("SmallPictureName") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); @@ -249,7 +249,7 @@ namespace Musify.Infrastructure.Persistence.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("BucketName") + b.Property("Bucket") .IsRequired() .HasColumnType("text"); @@ -260,7 +260,7 @@ namespace Musify.Infrastructure.Persistence.Migrations b.Property("CreatedTime") .HasColumnType("timestamp with time zone"); - b.Property("KeyName") + b.Property("Key") .IsRequired() .HasColumnType("text"); diff --git a/Infrastructure/Pictures/PictureHandler.cs b/Infrastructure/Pictures/PictureHandler.cs index f5c3a12..4bbf97c 100644 --- a/Infrastructure/Pictures/PictureHandler.cs +++ b/Infrastructure/Pictures/PictureHandler.cs @@ -13,7 +13,7 @@ namespace Musify.Infrastructure.Pictures { try { - logger.LogDebug("Resizing picture to {Width}x{Height}", width, height); + logger.LogDebug("Resizing picture to={Width}x{Height}", width, height); if (pictureStream.CanSeek && pictureStream.Position > 0) pictureStream.Position = 0; @@ -31,12 +31,12 @@ namespace Musify.Infrastructure.Pictures memoryStream.Position = 0; - logger.LogDebug("Picture resized successfully. OutputLength: {Length}", memoryStream.Length); + logger.LogDebug("Picture resized successfully. OutputLength={Length}", memoryStream.Length); return Result.Success(memoryStream); } catch (Exception exception) { - logger.LogError(exception, "An error occurred while resizing the picture to {Width}x{Height}.", width, height); + logger.LogError(exception, "An error occurred while resizing the picture to={Width}x{Height}.", width, height); return Result.Error("An error occurred while resizing the picture."); } } diff --git a/Infrastructure/Storage/StorageHandler.cs b/Infrastructure/Storage/StorageHandler.cs index 44fce65..3293281 100644 --- a/Infrastructure/Storage/StorageHandler.cs +++ b/Infrastructure/Storage/StorageHandler.cs @@ -13,61 +13,61 @@ namespace Musify.Infrastructure.Storage public class StorageHandler(IDatabase database, IAmazonS3 amazonS3, InfrastructureStorageConfiguration storageClientConfiguration, ILogger logger) : IStorageHandler { - public async Task> GetFileAsync(string bucketName, string keyName, CancellationToken cancellationToken) + public async Task> GetFileAsync(string bucket, string key, CancellationToken cancellationToken) { var request = new GetObjectRequest { - BucketName = bucketName, - Key = keyName, + BucketName = bucket, + Key = key, }; - logger.LogDebug("Getting file from S3. Bucket: {BucketName}, Key: {KeyName}", bucketName, keyName); + logger.LogDebug("Getting file from S3. Bucket={Bucket}, Key={Key}", bucket, key); try { var response = await amazonS3.GetObjectAsync(request, cancellationToken); - logger.LogDebug("Successfully got file from S3 with bucket name {BucketName} and key name {KeyName}", bucketName, keyName); + logger.LogDebug("Successfully got file from S3 with bucket={Bucket} and key={Key}", bucket, key); return Result.Success(response.ResponseStream); } catch (Exception exception) { - logger.LogWarning(exception, "Failed to get file from S3. Bucket: {BucketName}, Key: {KeyName}", bucketName, keyName); - return Result.NotFound($"File not found in S3 with bucket name {bucketName} and key name {keyName}"); + logger.LogWarning(exception, "Failed to get file from S3. Bucket={Bucket}, Key={Key}", bucket, key); + return Result.NotFound($"File not found in S3 with bucket: {bucket} and key: {key}"); } } - public async Task GetUrlAsync(string bucketName, string keyName, TimeSpan expirationTime, CancellationToken cancellationToken) + public async Task GetUrlAsync(string bucket, string key, TimeSpan expirationTime, CancellationToken cancellationToken) { var request = new GetPreSignedUrlRequest { - BucketName = bucketName, - Key = keyName, + BucketName = bucket, + Key = key, Expires = DateTime.UtcNow + expirationTime, Protocol = storageClientConfiguration.UseHttp ? Protocol.HTTP : Protocol.HTTPS }; - logger.LogDebug("Getting pre-signed URL from S3. Bucket: {BucketName}, Key: {KeyName}, Expires: {Expires}", bucketName, keyName, request.Expires); + logger.LogDebug("Getting pre-signed URL from S3. Bucket={BucketName}, Key={Key}, Expires={Expires}", bucket, key, request.Expires); var url = await amazonS3.GetPreSignedURLAsync(request); return url; } - public async Task RemoveFileAsync(string bucketName, string keyName, CancellationToken cancellationToken) + public async Task RemoveFileAsync(string bucket, string key, CancellationToken cancellationToken) { var request = new DeleteObjectRequest { - BucketName = bucketName, - Key = keyName, + BucketName = bucket, + Key = key, }; - logger.LogDebug("Removing file from S3. Bucket: {BucketName}, Key: {KeyName}", bucketName, keyName); + logger.LogDebug("Removing file from S3. Bucket={Bucket}, Key={Key}", bucket, key); var response = await amazonS3.DeleteObjectAsync(request, cancellationToken); return Result.NoContent(); } - public async Task TransferFilesAsync(string sourceDirectory, string bucketName, string route, CancellationToken cancellationToken) + public async Task TransferFilesAsync(string sourceDirectory, string bucket, string route, CancellationToken cancellationToken) { var trasnsferUtility = new TransferUtility(amazonS3); @@ -81,67 +81,67 @@ namespace Musify.Infrastructure.Storage string fileName = Path.GetFileName(file); string filePath = Path.Combine(sourceDirectory, file); - var keyName = Path.Combine(route, fileName); + var key = Path.Combine(route, fileName); var upload = new Upload { Id = Guid.NewGuid(), - BucketName = bucketName, - KeyName = keyName, - ContentType = "Application/Octet-Stream" + Bucket = bucket, + Key = key, + ContentType = MimeUtility.GetMimeMapping(filePath) }; await database.Uploads.AddAsync(upload, cancellationToken); try { - await trasnsferUtility.UploadAsync(filePath, bucketName, keyName, cancellationToken); + await trasnsferUtility.UploadAsync(filePath, bucket, key, cancellationToken); upload.State = UploadState.Successful; successCount++; - logger.LogDebug("Transferred file to S3. Bucket: {BucketName}, KeyName: {KeyName}", bucketName, keyName); + logger.LogDebug("Transferred file to S3. Bucket={Bucket}, Key={Key}", bucket, key); } catch (Exception exception) { failedCount++; upload.State = UploadState.Failed; - logger.LogError(exception, "Failed to transfer file to S3. Bucket: {BucketName}, keyName: {keyName}", bucketName, keyName); + logger.LogError(exception, "Failed to transfer file to S3. Bucket={Bucket}, key={key}", bucket, key); } } await database.SaveChangesAsync(cancellationToken); - logger.LogInformation("TransferFiles completed. Bucket: {BucketName}, Route: {Route}, Success: {SuccessCount}, Failed: {FailedCount}", bucketName, route, successCount, failedCount); + logger.LogInformation("TransferFiles completed. Bucket={Bucket}, Route={Route}, Success={SuccessCount}, Failed={FailedCount}", bucket, route, successCount, failedCount); return Result.Success(); } - public async Task> UploadFileAsync(string filePath, string bucketName, string keyName, CancellationToken cancellationToken) + public async Task> UploadFileAsync(string filePath, string bucket, string key, CancellationToken cancellationToken) { try { using var fileStream = File.OpenRead(filePath); var contentType = MimeUtility.GetMimeMapping(filePath); - return await UploadFileAsync(fileStream, contentType, bucketName, keyName, cancellationToken); + return await UploadFileAsync(fileStream, contentType, bucket, key, cancellationToken); } catch (Exception exception) { - logger.LogError(exception, "Failed to upload file to S3 with bucket name {BucketName} and key name {KeyName}", bucketName, keyName); - return Result.Error($"Failed to upload file to S3 with bucket name {bucketName} and key name {keyName}"); + logger.LogError(exception, "Failed to upload file to S3 with bucket={Bucket} and key={Key}", bucket, key); + return Result.Error($"Failed to upload file to S3 with bucket: {bucket} and key: {key}"); } } - public async Task> UploadFileAsync(Stream sourceStream, string contentType, string bucketName, string keyName, CancellationToken cancellationToken) + public async Task> UploadFileAsync(Stream sourceStream, string contentType, string bucket, string key, CancellationToken cancellationToken) { var request = new PutObjectRequest { - BucketName = bucketName, + BucketName = bucket, ContentType = contentType, InputStream = sourceStream, - Key = keyName + Key = key }; var upload = new Upload { Id = Guid.NewGuid(), - BucketName = bucketName, - KeyName = keyName, + Bucket = bucket, + Key = key, ContentType = contentType }; await database.Uploads.AddAsync(upload, cancellationToken); @@ -149,45 +149,45 @@ namespace Musify.Infrastructure.Storage try { var response = await amazonS3.PutObjectAsync(request, cancellationToken); - logger.LogDebug("Uploaded file to S3. Bucket: {BucketName}, Key: {KeyName}", bucketName, keyName); + logger.LogDebug("Uploaded file to S3. Bucket?={Bucket}, Key={Key}", bucket, key); } catch (Exception exception) { - logger.LogError(exception, "Failed to upload file to S3 with bucket name {BucketName} and key name {KeyName}", bucketName, keyName); + logger.LogError(exception, "Failed to upload file to S3 with bucket={Bucket} and key={Key}", bucket, key); upload.State = UploadState.Failed; - return Result.Error($"Failed to upload file to S3 with bucket name {bucketName} and key name {keyName}"); + return Result.Error($"Failed to upload file to S3 with bucket: {bucket} and key: {key}"); } upload.State = UploadState.Successful; await database.SaveChangesAsync(cancellationToken); - logger.LogDebug("Saved upload record to database. Bucket: {BucketName}, Key: {KeyName}", bucketName, keyName); + logger.LogDebug("Saved upload record to database. Bucket={Bucket}, Key={Key}", bucket, key); - return Result.Success(keyName); + return Result.Success(key); } - public async Task CopyFileAsync(string sourceBucketName, string sourceKeyName, string destinationBucketName, string destinationKeyName, + public async Task CopyFileAsync(string sourceBucket, string sourceKey, string destinationBucket, string destinationKey, CancellationToken cancellationToken) { var request = new CopyObjectRequest { - SourceBucket = sourceBucketName, - SourceKey = sourceKeyName, - DestinationBucket = destinationBucketName, - DestinationKey = destinationKeyName + SourceBucket = sourceBucket, + SourceKey = sourceKey, + DestinationBucket = destinationBucket, + DestinationKey = destinationKey }; try { var response = await amazonS3.CopyObjectAsync(request, cancellationToken); - logger.LogInformation("Successfully copied file from S3 with bucket name {SourceBucketName} and key name {SourceKeyName} to bucket name {DestinationBucketName} and key name {DestinationKeyName}", - sourceBucketName, sourceKeyName, destinationBucketName, destinationKeyName); + logger.LogInformation("Successfully copied file from S3 with bucket={SourceBucket} and key={SourceKey} to bucket={DestinationBucket} and key={DestinationKey}", + sourceBucket, sourceKey, destinationBucket, destinationKey); return Result.Success(); } catch (Exception exception) { - logger.LogError(exception, "Failed to copy file from S3 with bucket name {SourceBucketName} and key name {SourceKeyName} to bucket name {DestinationBucketName} and key name {DestinationKeyName}", - sourceBucketName, sourceKeyName, destinationBucketName, destinationKeyName); - return Result.Error($"Failed to copy file from S3 with bucket name {sourceBucketName} and key name {sourceKeyName} to bucket name {destinationBucketName} and key name {destinationKeyName}"); + logger.LogError(exception, "Failed to copy file from S3 with bucket={SourceBucket} and key={SourceKey} to bucket={DestinationBucket} and key={DestinationKey}", + sourceBucket, sourceKey, destinationBucket, destinationKey); + return Result.Error($"Failed to copy file from S3 with bucket: {sourceBucket} and key: {sourceKey} to bucket: {destinationBucket} and key: {destinationKey}"); } } }