Remove potential for deadlock in ProfileDataService

This commit is contained in:
Cj
2025-10-19 01:13:46 -04:00
parent 80b49eb077
commit fd47c47c3e
@@ -26,7 +26,7 @@ public class ProfileDataService(ISptLogger<ProfileDataService> logger, FileUtil
value = jsonUtil.Deserialize<T>(fileUtil.ReadFile($"{ProfileDataFilepath}{profileId}/{modKey}.json"));
if (value != null)
{
while (!_profileDataCache.TryAdd(profileDataKey, value)) { }
_profileDataCache[$"{profileId}:{modKey}"] = value;
}
}
else
@@ -48,8 +48,7 @@ public class ProfileDataService(ISptLogger<ProfileDataService> logger, FileUtil
throw new Exception("The profile data when serialized resulted in a null value");
}
while (!_profileDataCache.TryAdd($"{profileId}:{modKey}", profileData)) { }
_profileDataCache[$"{profileId}:{modKey}"] = profileData;
fileUtil.WriteFile($"{ProfileDataFilepath}{profileId}/{modKey}.json", data);
}
}