diff --git a/Controllers/Managers/DirectoryManager.cs b/Controllers/Managers/DirectoryManager.cs index 61af92a..d937695 100644 --- a/Controllers/Managers/DirectoryManager.cs +++ b/Controllers/Managers/DirectoryManager.cs @@ -48,6 +48,14 @@ namespace Icarus.Controllers.Managers try { _songDirectory = CreateDirectoryFromSong(); + + if (!Directory.Exists(_songDirectory)) + { + Directory.CreateDirectory(_songDirectory); + Console.WriteLine("The directory has been created"); + } + + Console.WriteLine($"The song will be saved in the following" + $" directory: {_songDirectory}"); } @@ -65,7 +73,7 @@ namespace Icarus.Controllers.Managers string CreateDirectoryFromSong() { string directory = _rootSongDirectory; - directory += $"{_song.Artist}//{_song.Album}//{_song.Title}.mp3"; + directory += $"{_song.Artist}//{_song.Album}//"; return directory; } diff --git a/Controllers/Managers/SongManager.cs b/Controllers/Managers/SongManager.cs index 4bb5610..61d4bc3 100644 --- a/Controllers/Managers/SongManager.cs +++ b/Controllers/Managers/SongManager.cs @@ -166,10 +166,18 @@ namespace Icarus.Controllers.Managers DirectoryManager dirMgr = new DirectoryManager(_config, _song); dirMgr.CreateDirectory(); filePath = dirMgr.SongDirectory; + if (!song.FileName.EndsWith(".mp3")) + filePath += $"{song.FileName}.mp3"; + else + filePath += $"{song.FileName}"; + + Console.WriteLine($"Full path {filePath}"); using (var fileStream = new FileStream(filePath, FileMode.Create)) { await song.CopyToAsync(fileStream); + _song.SongPath = filePath; + SaveSongDetails(); Console.WriteLine($"Writing song to the directory: {filePath}"); @@ -293,7 +301,6 @@ namespace Icarus.Controllers.Managers await song.CopyToAsync(fileStream); _song = RetrieveMetaData(filePath); _song.Filename = song.FileName; - SaveSongDetails(); } } diff --git a/Controllers/SongDataController.cs b/Controllers/SongDataController.cs index 6adf107..37a796f 100644 --- a/Controllers/SongDataController.cs +++ b/Controllers/SongDataController.cs @@ -69,7 +69,6 @@ namespace Icarus.Controllers Console.WriteLine($"Song Root Path {uploads}"); foreach (var sng in songData) { - byte[] data; if (sng.Length > 0) { await _songMgr.SaveSongToFileSystem(sng); } diff --git a/appsettings.Development.json b/appsettings.Development.json index 228531f..7a55dbe 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -9,5 +9,6 @@ "ConnectionStrings": { "IcarusDev":"Server=; User=; Password=; Database=; Port=" }, - "RootMusicPath":"/root/of/music/path/ + "RootMusicPath":"/root/music/path/", + "TemporaryMusicPath":"/root/temp/music/path/" } diff --git a/appsettings.json b/appsettings.json index 271b628..b5e6912 100644 --- a/appsettings.json +++ b/appsettings.json @@ -8,5 +8,6 @@ "ConnectionStrings": { "IcarusProd":"Server=; User=; Password=; Database=; Port=" }, - "RootMusicPath":"/root/of/music/path/" + "RootMusicPath":"/root/of/music/path/", + "TemporaryMusicPath":"/root/temp/music/path/" }