Handle invalid profiles on all IOnUpdate

This commit is contained in:
Archangel
2025-08-05 17:20:49 +02:00
parent d5514c6bb4
commit c3b36f4c7d
6 changed files with 52 additions and 16 deletions
@@ -56,7 +56,7 @@ public class ProfileValidatorService(
}
}
SptProfile sptReadyProfile;
SptProfile? sptReadyProfile = null;
try
{
@@ -76,15 +76,24 @@ public class ProfileValidatorService(
logger.Critical(ex.StackTrace);
}
sptReadyProfile = new()
// If profile has passed deserialization, but caught an exception on CheckForOrphanedModdedItems
if (sptReadyProfile?.ProfileInfo is not null)
{
ProfileInfo = new Info
sptReadyProfile.ProfileInfo.InvalidOrUnloadableProfile = true;
}
else
{
// Profile couldn't deserialize, make a small 'mock' profile to emulate it.
sptReadyProfile = new()
{
ProfileId = new Models.Common.MongoId(profileId),
Username = profile["info"]?["username"]?.GetValue<string>() ?? "",
InvalidOrUnloadableProfile = true,
},
};
ProfileInfo = new Info
{
ProfileId = new Models.Common.MongoId(profileId),
Username = profile["info"]?["username"]?.GetValue<string>() ?? "",
InvalidOrUnloadableProfile = true,
},
};
}
return sptReadyProfile;
}