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");
|
_logger.Info("Created album path");
|
||||||
}
|
}
|
||||||
|
|
||||||
songPath = $@"{albumPath}{song.Filename}";
|
songPath = albumPath;
|
||||||
|
|
||||||
return songPath;
|
return songPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1018,27 +1018,40 @@ namespace Icarus.Controllers.Managers
|
|||||||
_logger.Info("Change to song's album or artist");
|
_logger.Info("Change to song's album or artist");
|
||||||
|
|
||||||
DirectoryManager dirMgr = new DirectoryManager(_config);
|
DirectoryManager dirMgr = new DirectoryManager(_config);
|
||||||
|
var oldSongPath = updatedSongRecord.SongPath;
|
||||||
var newSongPath = dirMgr.GenerateSongPath(updatedSongRecord);
|
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}");
|
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");
|
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))
|
if (songStore.DoesSongExist(newSongRecord))
|
||||||
{
|
{
|
||||||
songStore.UpdateSong(updatedSongRecord);
|
songStore.UpdateSong(updatedSongRecord);
|
||||||
|
|||||||
Reference in New Issue
Block a user