Update paths
This commit is contained in:
@@ -19,16 +19,16 @@ namespace Musify.Application.Configuration
|
||||
public string ParentFolders { get; set; } = "PlayLists";
|
||||
|
||||
[Required]
|
||||
public string OriginalPictures { get; set; } = "OriginalPictures";
|
||||
public string OriginalPicturesFolder { get; set; } = "OriginalPictures";
|
||||
|
||||
[Required]
|
||||
public string SmallPictures { get; set; } = "SmallPictures";
|
||||
public string SmallPicturesFolder { get; set; } = "SmallPictures";
|
||||
|
||||
[Required]
|
||||
public string MediumPictures { get; set; } = "MediumPictures";
|
||||
public string MediumPicturesFolder { get; set; } = "MediumPictures";
|
||||
|
||||
[Required]
|
||||
public string LargePictures { get; set; } = "LargePictures";
|
||||
public string LargePicturesFolder { get; set; } = "LargePictures";
|
||||
|
||||
[Required]
|
||||
public string PresetOriginalPicture { get; set; } = "PresetOriginalPicture.webp";
|
||||
@@ -41,6 +41,20 @@ namespace Musify.Application.Configuration
|
||||
|
||||
[Required]
|
||||
public string PresetLargePicture { get; set; } = "PresetLargePicture.webp";
|
||||
|
||||
public string SmallPicturesPath => Path.Combine(ParentFolders, SmallPicturesFolder);
|
||||
|
||||
public string MediumPicturesPath => Path.Combine(ParentFolders, MediumPicturesFolder);
|
||||
|
||||
public string LargePicturesPath => Path.Combine(ParentFolders, LargePicturesFolder);
|
||||
|
||||
public string PresetSmallPicturePath => Path.Combine(ParentFolders, PresetSmallPicture);
|
||||
|
||||
public string PresetMediumPicturePath => Path.Combine(ParentFolders, PresetMediumPicture);
|
||||
|
||||
public string PresetLargePicturePath => Path.Combine(ParentFolders, PresetLargePicture);
|
||||
|
||||
public string OriginalPicturesPath => Path.Combine(ParentFolders, OriginalPicturesFolder);
|
||||
}
|
||||
|
||||
public class PlayListPicturesSizes
|
||||
|
||||
@@ -19,16 +19,16 @@ namespace Musify.Application.Configuration
|
||||
public string ParentFolder { get; set; } = "Tracks";
|
||||
|
||||
[Required]
|
||||
public string OriginalPictures { get; set; } = "OriginalPictures";
|
||||
public string OriginalPicturesFolder { get; set; } = "OriginalPictures";
|
||||
|
||||
[Required]
|
||||
public string SmallPictures { get; set; } = "SmallPictures";
|
||||
public string SmallPicturesFolder { get; set; } = "SmallPictures";
|
||||
|
||||
[Required]
|
||||
public string MediumPictures { get; set; } = "MediumPictures";
|
||||
public string MediumPicturesFolder { get; set; } = "MediumPictures";
|
||||
|
||||
[Required]
|
||||
public string LargePictures { get; set; } = "LargePictures";
|
||||
public string LargePicturesFolder { get; set; } = "LargePictures";
|
||||
|
||||
[Required]
|
||||
public string PresetOriginalPicture { get; set; } = "PresetOriginalPicture.webp";
|
||||
@@ -43,10 +43,28 @@ namespace Musify.Application.Configuration
|
||||
public string PresetLargePicture { get; set; } = "PresetLargePicture.webp";
|
||||
|
||||
[Required]
|
||||
public string OriginalAudios { get; set; } = "OriginalAudios";
|
||||
public string OriginalAudiosFolder { get; set; } = "OriginalAudios";
|
||||
|
||||
[Required]
|
||||
public string ProcessedAudio { get; set; } = "ProcessedAudios";
|
||||
public string ProcessedAudioFolder { get; set; } = "ProcessedAudios";
|
||||
|
||||
public string SmallPicturesPath => Path.Combine(ParentFolder, SmallPicturesFolder);
|
||||
|
||||
public string MediumPicturesPath => Path.Combine(ParentFolder, MediumPicturesFolder);
|
||||
|
||||
public string LargePicturesPath => Path.Combine(ParentFolder, LargePicturesFolder);
|
||||
|
||||
public string PresetSmallPicturePath => Path.Combine(ParentFolder, PresetSmallPicture);
|
||||
|
||||
public string PresetMediumPicturePath => Path.Combine(ParentFolder, PresetMediumPicture);
|
||||
|
||||
public string PresetLargePicturePath => Path.Combine(ParentFolder, PresetLargePicture);
|
||||
|
||||
public string OriginalPicturesPath => Path.Combine(ParentFolder, OriginalPicturesFolder);
|
||||
|
||||
public string OriginalAudiosPath => Path.Combine(ParentFolder, OriginalAudiosFolder);
|
||||
|
||||
public string ProcessedAudiosPath => Path.Combine(ParentFolder, ProcessedAudioFolder);
|
||||
}
|
||||
|
||||
public class TrackPicturesSizes
|
||||
|
||||
@@ -56,9 +56,7 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
{
|
||||
var imageId = Guid.NewGuid();
|
||||
var pictureName = imageId + picture.FileType;
|
||||
var pictureStorageKey = Path.Join(
|
||||
playListConfiguration.Routes.ParentFolders,
|
||||
playListConfiguration.Routes.OriginalPictures,
|
||||
var pictureStorageKey = Path.Join(playListConfiguration.Routes.OriginalPicturesPath,
|
||||
pictureName);
|
||||
|
||||
var uploadResult = await UploadFile(picture, pictureStorageKey, cancellationToken);
|
||||
@@ -99,18 +97,12 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
|
||||
async Task PublishUpdateEvent(string originalPictureKeyName, PlayList playList, CancellationToken cancellationToken)
|
||||
{
|
||||
var smallPictureKeyName = Path.Combine(
|
||||
playListConfiguration.Routes.ParentFolders,
|
||||
playListConfiguration.Routes.SmallPictures,
|
||||
$"{playList.Id}.{pictureHandler.FileExtension}");
|
||||
var mediumPictureKeyName = Path.Combine(
|
||||
playListConfiguration.Routes.ParentFolders,
|
||||
playListConfiguration.Routes.MediumPictures,
|
||||
$"{playList.Id}.{pictureHandler.FileExtension}");
|
||||
var largePictureKeyName = Path.Combine(
|
||||
playListConfiguration.Routes.ParentFolders,
|
||||
playListConfiguration.Routes.LargePictures,
|
||||
$"{playList.Id}.{pictureHandler.FileExtension}");
|
||||
var smallPictureKeyName = Path.Combine(playListConfiguration.Routes.SmallPicturesPath,
|
||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
||||
var mediumPictureKeyName = Path.Combine(playListConfiguration.Routes.MediumPicturesPath,
|
||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
||||
var largePictureKeyName = Path.Combine(playListConfiguration.Routes.LargePicturesPath,
|
||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
||||
|
||||
await eventBus.PublishAsync(new UpdatePlayListPictureEvent(
|
||||
playList.Id,
|
||||
|
||||
@@ -31,19 +31,13 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
var keysToRemove = new List<string>();
|
||||
|
||||
if (playList.SmallPictureKeyName != playListConfiguration.Routes.PresetSmallPicture)
|
||||
keysToRemove.Add(Path.Combine(
|
||||
playListConfiguration.Routes.ParentFolders,
|
||||
playListConfiguration.Routes.SmallPictures,
|
||||
keysToRemove.Add(Path.Combine(playListConfiguration.Routes.SmallPicturesPath,
|
||||
playList.SmallPictureKeyName));
|
||||
if (playList.MediumPictureKeyName != playListConfiguration.Routes.PresetMediumPicture)
|
||||
keysToRemove.Add(Path.Combine(
|
||||
playListConfiguration.Routes.ParentFolders,
|
||||
playListConfiguration.Routes.MediumPictures,
|
||||
keysToRemove.Add(Path.Combine(playListConfiguration.Routes.MediumPicturesPath,
|
||||
playList.MediumPictureKeyName));
|
||||
if (playList.LargePictureKeyName != playListConfiguration.Routes.PresetLargePicture)
|
||||
keysToRemove.Add(Path.Combine(
|
||||
playListConfiguration.Routes.ParentFolders,
|
||||
playListConfiguration.Routes.LargePictures,
|
||||
keysToRemove.Add(Path.Combine(playListConfiguration.Routes.LargePicturesPath,
|
||||
playList.LargePictureKeyName));
|
||||
|
||||
foreach (var key in keysToRemove)
|
||||
|
||||
@@ -53,20 +53,23 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
|
||||
if (playList.SmallPictureKeyName != playListConfiguration.Routes.PresetSmallPicture)
|
||||
await PublishRemoveFileEvent(Path.Combine(
|
||||
playListConfiguration.Routes.SmallPictures,
|
||||
playList.SmallPictureKeyName), cancellationToken);
|
||||
playListConfiguration.Routes.SmallPicturesPath,
|
||||
playList.SmallPictureKeyName),
|
||||
cancellationToken);
|
||||
if (playList.MediumPictureKeyName != playListConfiguration.Routes.PresetMediumPicture)
|
||||
await PublishRemoveFileEvent(Path.Combine(
|
||||
playListConfiguration.Routes.MediumPictures,
|
||||
playList.MediumPictureKeyName), cancellationToken);
|
||||
playListConfiguration.Routes.MediumPicturesPath,
|
||||
playList.MediumPictureKeyName),
|
||||
cancellationToken);
|
||||
if (playList.LargePictureKeyName != playListConfiguration.Routes.PresetLargePicture)
|
||||
await PublishRemoveFileEvent(Path.Combine(
|
||||
playListConfiguration.Routes.LargePictures,
|
||||
playList.LargePictureKeyName), cancellationToken);
|
||||
playListConfiguration.Routes.LargePicturesPath,
|
||||
playList.LargePictureKeyName),
|
||||
cancellationToken);
|
||||
|
||||
var newImageId = Guid.NewGuid();
|
||||
var pictureName = newImageId + request.NewPicture.FileType;
|
||||
var newImageStorageKey = Path.Join(playListConfiguration.Routes.OriginalPictures, pictureName);
|
||||
var newImageStorageKey = Path.Combine(playListConfiguration.Routes.OriginalPicturesPath, pictureName);
|
||||
|
||||
var uploadResult = await UploadFile(request.NewPicture, newImageStorageKey, cancellationToken);
|
||||
if (!uploadResult.IsSuccess)
|
||||
@@ -127,14 +130,14 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
async Task PublishUpdateEvent(string originalPictureKeyName, PlayList playList, CancellationToken cancellationToken)
|
||||
{
|
||||
var smallPictureKeyName = Path.Combine(
|
||||
playListConfiguration.Routes.SmallPictures,
|
||||
$"{playList.Id}.{pictureHandler.FileExtension}");
|
||||
playListConfiguration.Routes.SmallPicturesPath,
|
||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
||||
var mediumPictureKeyName = Path.Combine(
|
||||
playListConfiguration.Routes.MediumPictures,
|
||||
$"{playList.Id}.{pictureHandler.FileExtension}");
|
||||
playListConfiguration.Routes.MediumPicturesPath,
|
||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
||||
var largePictureKeyName = Path.Combine(
|
||||
playListConfiguration.Routes.LargePictures,
|
||||
$"{playList.Id}.{pictureHandler.FileExtension}");
|
||||
playListConfiguration.Routes.LargePicturesPath,
|
||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
||||
|
||||
await eventBus.PublishAsync(new UpdatePlayListPictureEvent(
|
||||
playList.Id,
|
||||
|
||||
@@ -33,14 +33,12 @@ namespace Musify.Application.Tracks.Handler
|
||||
NormalizedTitle = request.Title.Trim().ToUpperInvariant(),
|
||||
OriginalPictureKeyName = originalPictureFileName,
|
||||
OriginalAudioKeyName = originalAudioFileName,
|
||||
SmallPictureKeyName = trackConfiguration.Routes.PresetSmallPicture,
|
||||
SmallPictureKeyName = trackConfiguration.Routes.PresetMediumPicture,
|
||||
MediumPictureKeyName = trackConfiguration.Routes.PresetMediumPicture,
|
||||
LargePictureKeyName = trackConfiguration.Routes.PresetLargePicture,
|
||||
};
|
||||
|
||||
var originalPictureKeyName = Path.Combine(
|
||||
trackConfiguration.Routes.ParentFolder,
|
||||
trackConfiguration.Routes.OriginalPictures,
|
||||
var originalPictureKeyName = Path.Combine(trackConfiguration.Routes.PresetMediumPicture,
|
||||
originalPictureFileName);
|
||||
var pictureUploadResult = await UploadFile(request.Picture, originalPictureKeyName, cancellationToken);
|
||||
if (!pictureUploadResult.IsSuccess)
|
||||
@@ -50,9 +48,7 @@ namespace Musify.Application.Tracks.Handler
|
||||
}
|
||||
|
||||
|
||||
var audioKeyName = Path.Combine(
|
||||
trackConfiguration.Routes.ParentFolder,
|
||||
trackConfiguration.Routes.OriginalAudios,
|
||||
var audioKeyName = Path.Combine(trackConfiguration.Routes.OriginalAudiosFolder,
|
||||
Guid.NewGuid() + request.Audio.FileType);
|
||||
var audioUploadResult = await UploadFile(request.Audio, audioKeyName, cancellationToken);
|
||||
if (!audioUploadResult.IsSuccess)
|
||||
@@ -101,18 +97,12 @@ namespace Musify.Application.Tracks.Handler
|
||||
|
||||
async Task PublishUpdateEvent(string originalPictureKeyName, Track track, CancellationToken cancellationToken)
|
||||
{
|
||||
var smallPictureKeyName = Path.Combine(
|
||||
trackConfiguration.Routes.ParentFolder,
|
||||
trackConfiguration.Routes.SmallPictures,
|
||||
$"{track.Id}.{pictureHandler.FileExtension}");
|
||||
var mediumPictureKeyName = Path.Combine(
|
||||
trackConfiguration.Routes.ParentFolder,
|
||||
trackConfiguration.Routes.MediumPictures,
|
||||
$"{track.Id}.{pictureHandler.FileExtension}");
|
||||
var largePictureKeyName = Path.Combine(
|
||||
trackConfiguration.Routes.ParentFolder,
|
||||
trackConfiguration.Routes.LargePictures,
|
||||
$"{track.Id}.{pictureHandler.FileExtension}");
|
||||
var smallPictureKeyName = Path.Combine(trackConfiguration.Routes.MediumPicturesPath,
|
||||
track.Id + pictureHandler.FileExtension);
|
||||
var mediumPictureKeyName = Path.Combine(trackConfiguration.Routes.MediumPicturesPath,
|
||||
track.Id + pictureHandler.FileExtension);
|
||||
var largePictureKeyName = Path.Combine(trackConfiguration.Routes.LargePicturesPath,
|
||||
track.Id + pictureHandler.FileExtension);
|
||||
|
||||
await eventBus.PublishAsync(new UpdateTrackPictureEvent(
|
||||
track.Id,
|
||||
@@ -131,9 +121,7 @@ namespace Musify.Application.Tracks.Handler
|
||||
|
||||
async Task PublishTranscodeEvent(Guid trackId, string audioKeyName, CancellationToken cancellationToken)
|
||||
{
|
||||
var destinationFolderAudio = Path.Combine(
|
||||
trackConfiguration.Routes.ParentFolder,
|
||||
trackConfiguration.Routes.ProcessedAudio,
|
||||
var destinationFolderAudio = Path.Combine(trackConfiguration.Routes.ProcessedAudioFolder,
|
||||
Guid.NewGuid().ToString());
|
||||
|
||||
await eventBus.PublishAsync(new UpdateTrackAudioEvent(
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user