mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 13:42:24 +00:00
Optimize RemoveInvalidServerResult
This commit is contained in:
parent
317a5da120
commit
deafd73306
2 changed files with 12 additions and 15 deletions
|
@ -294,7 +294,7 @@ namespace ServiceLib.Handler
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
/// <param name="indexes"></param>
|
/// <param name="indexes"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<int> RemoveServer(Config config, List<ProfileItem> indexes)
|
public static async Task<int> RemoveServers(Config config, List<ProfileItem> indexes)
|
||||||
{
|
{
|
||||||
var subid = "TempRemoveSubId";
|
var subid = "TempRemoveSubId";
|
||||||
foreach (var item in indexes)
|
foreach (var item in indexes)
|
||||||
|
@ -303,7 +303,7 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
await SQLiteHelper.Instance.UpdateAllAsync(indexes);
|
await SQLiteHelper.Instance.UpdateAllAsync(indexes);
|
||||||
await RemoveServerViaSubid(config, subid, false);
|
await RemoveServersViaSubid(config, subid, false);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -886,7 +886,7 @@ namespace ServiceLib.Handler
|
||||||
lstRemove.Add(item);
|
lstRemove.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await RemoveServer(config, lstRemove);
|
await RemoveServers(config, lstRemove);
|
||||||
|
|
||||||
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
|
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
|
||||||
}
|
}
|
||||||
|
@ -1062,12 +1062,9 @@ namespace ServiceLib.Handler
|
||||||
var lstProfile = (from t in lstModel
|
var lstProfile = (from t in lstModel
|
||||||
join t2 in lstProfileExs on t.IndexId equals t2.IndexId
|
join t2 in lstProfileExs on t.IndexId equals t2.IndexId
|
||||||
where t2.Delay == -1
|
where t2.Delay == -1
|
||||||
select t.IndexId).ToList();
|
select t).ToList();
|
||||||
|
|
||||||
foreach (var item in lstProfile)
|
await RemoveServers(config, JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(lstProfile)));
|
||||||
{
|
|
||||||
await RemoveProfileItem(config, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return lstProfile.Count;
|
return lstProfile.Count;
|
||||||
}
|
}
|
||||||
|
@ -1094,7 +1091,7 @@ namespace ServiceLib.Handler
|
||||||
//remove sub items
|
//remove sub items
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && Utils.IsNotEmpty(subid))
|
||||||
{
|
{
|
||||||
await RemoveServerViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
subFilter = (await AppHandler.Instance.GetSubItem(subid))?.Filter ?? "";
|
subFilter = (await AppHandler.Instance.GetSubItem(subid))?.Filter ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1188,7 +1185,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && Utils.IsNotEmpty(subid))
|
||||||
{
|
{
|
||||||
await RemoveServerViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (var it in lstProfiles)
|
foreach (var it in lstProfiles)
|
||||||
|
@ -1244,7 +1241,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && Utils.IsNotEmpty(subid))
|
||||||
{
|
{
|
||||||
await RemoveServerViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
profileItem.Subid = subid;
|
profileItem.Subid = subid;
|
||||||
|
@ -1269,7 +1266,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && Utils.IsNotEmpty(subid))
|
||||||
{
|
{
|
||||||
await RemoveServerViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lstSsServer = ShadowsocksFmt.ResolveSip008(strData);
|
var lstSsServer = ShadowsocksFmt.ResolveSip008(strData);
|
||||||
|
@ -1456,7 +1453,7 @@ namespace ServiceLib.Handler
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
/// <param name="subid"></param>
|
/// <param name="subid"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<int> RemoveServerViaSubid(Config config, string subid, bool isSub)
|
public static async Task<int> RemoveServersViaSubid(Config config, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(subid))
|
if (Utils.IsNullOrEmpty(subid))
|
||||||
{
|
{
|
||||||
|
@ -1487,7 +1484,7 @@ namespace ServiceLib.Handler
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
await SQLiteHelper.Instance.DeleteAsync(item);
|
await SQLiteHelper.Instance.DeleteAsync(item);
|
||||||
await RemoveServerViaSubid(config, id, false);
|
await RemoveServersViaSubid(config, id, false);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -520,7 +520,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
var exists = lstSelecteds.Exists(t => t.IndexId == _config.IndexId);
|
var exists = lstSelecteds.Exists(t => t.IndexId == _config.IndexId);
|
||||||
|
|
||||||
await ConfigHandler.RemoveServer(_config, lstSelecteds);
|
await ConfigHandler.RemoveServers(_config, lstSelecteds);
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
if (lstSelecteds.Count == _profileItems.Count)
|
if (lstSelecteds.Count == _profileItems.Count)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue