diff --git a/Controllers/Managers/DirectoryManager.cs b/Controllers/Managers/DirectoryManager.cs index 567349d..2d11c5e 100644 --- a/Controllers/Managers/DirectoryManager.cs +++ b/Controllers/Managers/DirectoryManager.cs @@ -113,7 +113,7 @@ namespace Icarus.Controllers.Managers _logger.Info("Created album path"); } - songPath = $@"{albumPath}{song.Filename}"; + songPath = albumPath; return songPath; } diff --git a/Controllers/Managers/SongManager.cs b/Controllers/Managers/SongManager.cs index cddb08d..9cbdb39 100644 --- a/Controllers/Managers/SongManager.cs +++ b/Controllers/Managers/SongManager.cs @@ -1018,27 +1018,40 @@ namespace Icarus.Controllers.Managers _logger.Info("Change to song's album or artist"); DirectoryManager dirMgr = new DirectoryManager(_config); + var oldSongPath = updatedSongRecord.SongPath; var newSongPath = dirMgr.GenerateSongPath(updatedSongRecord); + var filename = updatedSongRecord.Filename; - Console.WriteLine($"Old song path {updatedSongRecord.SongPath}"); + Console.WriteLine($"Old song path {oldSongPath}"); Console.WriteLine($"New song path {newSongPath}"); - System.IO.File.Copy(updatedSongRecord.SongPath, newSongPath, true); + _logger.Info("Copying song to the new path"); - if (!System.IO.File.Exists(newSongPath)) + System.IO.File.Copy(oldSongPath, newSongPath + filename, true); + + _logger.Info("Checking to see if song successfully copied"); + + if (!System.IO.File.Exists(newSongPath + filename)) { + _logger.Info("Song did not successfully copy"); + Console.WriteLine("New path does not exist when it should"); } - if (System.IO.File.Exists(updatedSongRecord.SongPath)) - { - Console.WriteLine("Old path exists when it should"); - } - updatedSongRecord.SongPath = newSongPath; + updatedSongRecord.SongPath = newSongPath + filename; - System.IO.File.Delete(updatedSongRecord.SongPath); + _logger.Info("Deleting old song path"); + + System.IO.File.Delete(oldSongPath); + + if (System.IO.File.Exists(oldSongPath)) + { + Console.WriteLine("Old path exists when it should not"); + } } + _logger.Info("Saving song metadata to the database"); + if (songStore.DoesSongExist(newSongRecord)) { songStore.UpdateSong(updatedSongRecord);