From 5e82827fc018a49b61a1eea7367e273470ca40a5 Mon Sep 17 00:00:00 2001 From: Slendy Date: Sat, 12 Nov 2022 11:21:31 -0600 Subject: [PATCH] Fix game server photo deletion bug Fix bug where users couldn't delete photos with empty subjects --- .../Controllers/Resources/PhotosController.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs index 389996e2..e3437ff5 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs @@ -223,7 +223,9 @@ public class PhotosController : ControllerBase } foreach (string idStr in photo.PhotoSubjectIds) { - if (!int.TryParse(idStr, out int subjectId)) throw new InvalidCastException(idStr + " is not a valid number."); + if (string.IsNullOrWhiteSpace(idStr)) continue; + + if (!int.TryParse(idStr, out int subjectId)) continue; this.database.PhotoSubjects.RemoveWhere(p => p.PhotoSubjectId == subjectId); }