diff --git a/Migrations/00000000000000_StoredProcedure.cs b/Migrations/00000000000000_StoredProcedure.cs
index f45eaf3..7166608 100644
--- a/Migrations/00000000000000_StoredProcedure.cs
+++ b/Migrations/00000000000000_StoredProcedure.cs
@@ -13,7 +13,7 @@ public partial class _00000000000000_StoredProcedure : Migration
AS $$
BEGIN
DELETE FROM "Songs"
- WHERE "State" = 0;
+ WHERE "State" = 1;
COMMIT;
END;
diff --git a/Shadow.csproj b/Shadow.csproj
index d5fcfe7..7898dcb 100644
--- a/Shadow.csproj
+++ b/Shadow.csproj
@@ -44,9 +44,7 @@
-
-
diff --git a/Tools/Cli.cs b/Tools/Cli.cs
index 1f56141..abad071 100644
--- a/Tools/Cli.cs
+++ b/Tools/Cli.cs
@@ -349,7 +349,8 @@ public class Cli
{
File.Copy(
Path.Combine(currentPath, "Assets", "vinyl.png"),
- Path.Combine(newMusicThumbnailPath, "default.png")
+ Path.Combine(newMusicThumbnailPath, "default.png"),
+ true
);
break;
}
@@ -357,7 +358,7 @@ public class Cli
currentPath = Path.Combine(currentPath, "..");
if (i == 5) Console.WriteLine("\n" +
- "Error: Could not determine content root path. \n" +
+ "[Error] Could not determine content root path. \n" +
"Please place Assets/vinyl.png in your thumbnail path directory manually\n" +
"and rename it to default.png.");
}
@@ -385,7 +386,10 @@ public class Cli
int rowsAffected = 0;
// Retrieve orphaned songs
- List orphanedSongs = db.Songs.Where(s => s.State == 1).ToList();
+ List orphanedSongs = db.Songs
+ .Where(s => s.State == 1)
+ .Include(s => s.Album)
+ .ToList();
// Ask if it's alright to remove them
// and related listening data permanently
@@ -413,11 +417,13 @@ public class Cli
// TODO: Remove song images if not used by any other resource
// ...
+
+ db.SaveChanges();
}
// Perform cleanup with stored procedure
- rowsAffected += db.Database.ExecuteSqlRaw("CALL song_cleanup()");
- // rowsAffected += songs.Count;
+ db.Database.ExecuteSqlRaw("CALL song_cleanup()");
+ rowsAffected += orphanedSongs.Count;
}
}
else Console.WriteLine("No orphaned songs found.");
@@ -434,13 +440,17 @@ public class Cli
{
db.Albums.RemoveRange(orphanedAlbums);
rowsAffected += orphanedAlbums.Count;
+ db.SaveChanges();
}
}
else Console.WriteLine("No orphaned albums found.");
// Retrieve orphaned artists (artists with no songs AND albums)
- List orphanedArtists = db.Artists.Where(a => a.Songs.Count == 0 && a.Albums.Count == 0).ToList();
- Artist? unknownArtist = db.Artists.FirstOrDefault(a => a.NormalizedName == "[unknown artist]");
+ List orphanedArtists = db.Artists
+ .Where(a => a.Songs.Count == 0 && a.Albums.Count == 0)
+ .ToList();
+ Artist? unknownArtist = db.Artists
+ .FirstOrDefault(a => a.NormalizedName == "[unknown artist]");
// Account for the [Unknown Artist],
// which is a meta-artist and shall