Able to update the song's metadata and move the old song file to a new path and delete the old song path. Need to imlement functionality to revert changes incase something goes wrong. #37
This commit is contained in:
@@ -113,7 +113,7 @@ namespace Icarus.Controllers.Managers
|
||||
_logger.Info("Created album path");
|
||||
}
|
||||
|
||||
songPath = $@"{albumPath}{song.Filename}";
|
||||
songPath = albumPath;
|
||||
|
||||
return songPath;
|
||||
}
|
||||
|
||||
@@ -1018,26 +1018,39 @@ 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))
|
||||
|
||||
updatedSongRecord.SongPath = newSongPath + filename;
|
||||
|
||||
_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");
|
||||
Console.WriteLine("Old path exists when it should not");
|
||||
}
|
||||
}
|
||||
|
||||
updatedSongRecord.SongPath = newSongPath;
|
||||
|
||||
System.IO.File.Delete(updatedSongRecord.SongPath);
|
||||
}
|
||||
_logger.Info("Saving song metadata to the database");
|
||||
|
||||
if (songStore.DoesSongExist(newSongRecord))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user