Handle collision case when generating hid

This commit is contained in:
xBelladonna 2019-07-27 14:00:05 +09:30 committed by Astrid
parent 924924b10e
commit 29eefd7f5a

View File

@ -18,8 +18,11 @@ namespace PluralKit {
}
public async Task<PKSystem> Create(string systemName = null) {
// TODO: handle HID collision case
var hid = Utils.GenerateHid();
string hid;
do
{
hid = Utils.GenerateHid();
} while (await GetByHid(hid) != null);
PKSystem system;
using (var conn = await _conn.Obtain())
@ -103,8 +106,11 @@ namespace PluralKit {
}
public async Task<PKMember> Create(PKSystem system, string name) {
// TODO: handle collision
var hid = Utils.GenerateHid();
string hid;
do
{
hid = Utils.GenerateHid();
} while (await GetByHid(hid) != null);
PKMember member;
using (var conn = await _conn.Obtain())