diff --git a/v2rayN/ServiceLib/Manager/AppManager.cs b/v2rayN/ServiceLib/Manager/AppManager.cs index 1951cce0..e4d53c3e 100644 --- a/v2rayN/ServiceLib/Manager/AppManager.cs +++ b/v2rayN/ServiceLib/Manager/AppManager.cs @@ -262,8 +262,11 @@ public sealed class AppManager public async Task MigrateProfileExtra() { #pragma warning disable CS0618 + var list = await SQLiteHelper.Instance.TableAsync().ToListAsync(); + var groupItems = new ConcurrentDictionary(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!)); + const int pageSize = 500; - int offset = 0; + var offset = 0; while (true) { @@ -286,7 +289,7 @@ public sealed class AppManager if (item.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain) { extra.GroupType = nameof(item.ConfigType); - ProfileGroupItemManager.Instance.TryGet(item.IndexId, out var groupItem); + groupItems.TryGetValue(item.IndexId, out var groupItem); if (groupItem != null && !groupItem.NotHasChild()) { extra.ChildItems = groupItem.ChildItems; diff --git a/v2rayN/ServiceLib/Manager/ProfileGroupItemManager.cs b/v2rayN/ServiceLib/Manager/ProfileGroupItemManager.cs deleted file mode 100644 index 97b037d1..00000000 --- a/v2rayN/ServiceLib/Manager/ProfileGroupItemManager.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace ServiceLib.Manager; - -[Obsolete("Use GroupProfileManager instead.")] -public class ProfileGroupItemManager -{ - private static readonly Lazy _instance = new(() => new()); - private ConcurrentDictionary _items = new(); - - public static ProfileGroupItemManager Instance => _instance.Value; - private static readonly string _tag = "ProfileGroupItemManager"; - - private ProfileGroupItemManager() - { - } - - public async Task Init() - { - await InitData(); - } - - // Read-only getters: do not create or mark dirty - public bool TryGet(string indexId, out ProfileGroupItem? item) - { - item = null; - if (string.IsNullOrWhiteSpace(indexId)) - { - return false; - } - - return _items.TryGetValue(indexId, out item); - } - - private async Task InitData() - { - await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileGroupItem where IndexId not in ( select indexId from ProfileItem )"); - - var list = await SQLiteHelper.Instance.TableAsync().ToListAsync(); - _items = new ConcurrentDictionary(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!)); - } - - public async Task ClearAll() - { - await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileGroupItem "); - _items.Clear(); - } -} diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index a09ad4de..8f5e9029 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -259,7 +259,6 @@ public class MainWindowViewModel : MyReactiveObject await ConfigHandler.InitBuiltinDNS(_config); await ConfigHandler.InitBuiltinFullConfigTemplate(_config); await ProfileExManager.Instance.Init(); - await ProfileGroupItemManager.Instance.Init(); await CoreManager.Instance.Init(_config, UpdateHandler); TaskManager.Instance.RegUpdateTask(_config, UpdateTaskHandler);