Fix subscription update duplicate server bug

This commit is contained in:
2dust 2023-04-04 20:19:52 +08:00
parent 23c7d7fb46
commit 1a7dca8e58

View file

@ -933,6 +933,8 @@ namespace v2rayN.Handler
} }
int countServers = 0; int countServers = 0;
//Check for duplicate indexId
List<string>? lstDbIndexId = null;
List<ProfileItem> lstAdd = new(); List<ProfileItem> lstAdd = new();
string[] arrData = clipboardData.Split(Environment.NewLine.ToCharArray()); string[] arrData = clipboardData.Split(Environment.NewLine.ToCharArray());
foreach (string str in arrData) foreach (string str in arrData)
@ -957,9 +959,22 @@ namespace v2rayN.Handler
{ {
var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub && CompareProfileItem(t, profileItem, true)); var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub && CompareProfileItem(t, profileItem, true));
if (existItem != null) if (existItem != null)
{
//Check for duplicate indexId
if (lstDbIndexId is null)
{
lstDbIndexId = LazyConfig.Instance.ProfileItemIndexs("");
}
if (lstAdd.Any(t => t.indexId == existItem.indexId)
|| lstDbIndexId.Any(t => t == existItem.indexId))
{
profileItem.indexId = string.Empty;
}
else
{ {
profileItem.indexId = existItem.indexId; profileItem.indexId = existItem.indexId;
} }
}
//filter //filter
if (!Utils.IsNullOrEmpty(subFilter)) if (!Utils.IsNullOrEmpty(subFilter))
{ {