From 55fc031e4c2b8e008fb28247fb940679703591a2 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Fri, 14 Jun 2024 19:39:14 -0400 Subject: [PATCH] Added functionality to delete song directories --- Controllers/Managers/SongManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Controllers/Managers/SongManager.cs b/Controllers/Managers/SongManager.cs index 508b311..3fb3f52 100644 --- a/Controllers/Managers/SongManager.cs +++ b/Controllers/Managers/SongManager.cs @@ -145,7 +145,7 @@ public class SongManager : BaseManager { try { - if (DeleteSongFromFilesystem(song)) + if (DeleteSongFromFilesystem(song, true)) { _logger.Error("Failed to delete the song"); @@ -400,7 +400,7 @@ public class SongManager : BaseManager } - private bool DeleteSongFromFilesystem(Song song) + private bool DeleteSongFromFilesystem(Song song, bool deleteDirectory = false) { var songPath = song.SongPath(); @@ -409,6 +409,8 @@ public class SongManager : BaseManager try { System.IO.File.Delete(songPath); + + DeleteEmptyDirectories(ref song, ref song); } catch(Exception ex) { @@ -419,6 +421,7 @@ public class SongManager : BaseManager return DoesSongExistOnFilesystem(song); } + private bool DoesSongExistOnFilesystem(Song song) { if (!System.IO.File.Exists(song.SongPath()))