Fix subscription update duplicate server bug

pull/3611/head
2dust 2023-04-04 20:19:52 +08:00
parent 23c7d7fb46
commit 1a7dca8e58
1 changed files with 16 additions and 1 deletions

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)
@ -958,7 +960,20 @@ 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)
{ {
profileItem.indexId = existItem.indexId; //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;
}
} }
//filter //filter
if (!Utils.IsNullOrEmpty(subFilter)) if (!Utils.IsNullOrEmpty(subFilter))