Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Oct 25, 2024
1 parent 9bc50a9 commit 5effbee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Handler/AppHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ from ProfileItem a
await ConfigHandler.SetDefaultServer(_config, lstModel);

var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
var lstProfileExs = ProfileExHandler.Instance.ProfileExs;
var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs();
lstModel = (from t in lstModel
join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b
from t22 in t2b.DefaultIfEmpty()
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Handler/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ public static async Task<int> SortServers(Config config, string subId, string co
{
return -1;
}
var lstProfileExs = ProfileExHandler.Instance.ProfileExs;
var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs();
var lstProfile = (from t in lstModel
join t3 in lstProfileExs on t.IndexId equals t3.IndexId into t3b
from t33 in t3b.DefaultIfEmpty()
Expand Down
14 changes: 9 additions & 5 deletions v2rayN/ServiceLib/Handler/ProfileExHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,31 @@ public class ProfileExHandler
private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
private Queue<string> _queIndexIds = new();
public ConcurrentBag<ProfileExItem> ProfileExs => _lstProfileEx;
public static ProfileExHandler Instance => _instance.Value;

public ProfileExHandler()
{
Init();
//Init();
}

private async Task Init()
public async Task Init()
{
await InitData();
await Task.Run(async () =>
Task.Run(async () =>
{
while (true)
{
await SaveQueueIndexIds();
await Task.Delay(1000 * 600);
await SaveQueueIndexIds();
}
});
}

public async Task<ConcurrentBag<ProfileExItem>> GetProfileExs()
{
return _lstProfileEx;
}

private async Task InitData()
{
await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileExItem where indexId not in ( select indexId from ProfileItem )");
Expand Down
1 change: 1 addition & 0 deletions v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private async Task Init()

await ConfigHandler.InitBuiltinRouting(_config);
await ConfigHandler.InitBuiltinDNS(_config);
await ProfileExHandler.Instance.Init();
await CoreHandler.Instance.Init(_config, UpdateHandler);
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);

Expand Down

0 comments on commit 5effbee

Please sign in to comment.