mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-03 19:15:04 +03:00
fix: persist repeated profile test results (#10466)
This commit is contained in:
@@ -39,15 +39,14 @@ public class ProfileExManager
|
||||
{
|
||||
if (indexId.IsNotEmpty())
|
||||
{
|
||||
//Speed tests touch this from many threads; duplicates are harmless here since
|
||||
//the save loop just writes the same row more than once
|
||||
//Speed tests touch this from many threads; the save loop deduplicates IDs.
|
||||
_queIndexIds.Enqueue(indexId);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveQueueIndexIds()
|
||||
{
|
||||
var lstIds = new List<string>();
|
||||
var lstIds = new HashSet<string>();
|
||||
while (_queIndexIds.TryDequeue(out var id))
|
||||
{
|
||||
lstIds.Add(id);
|
||||
@@ -55,39 +54,25 @@ public class ProfileExManager
|
||||
|
||||
if (lstIds.Count > 0)
|
||||
{
|
||||
var lstExists = await SQLiteHelper.Instance.TableAsync<ProfileExItem>().ToListAsync();
|
||||
List<ProfileExItem> lstInserts = [];
|
||||
List<ProfileExItem> lstUpdates = [];
|
||||
List<ProfileExItem> lstSaves = [];
|
||||
|
||||
foreach (var id in lstIds)
|
||||
{
|
||||
var item = lstExists.FirstOrDefault(t => t.IndexId == id);
|
||||
var itemNew = _lstProfileEx?.FirstOrDefault(t => t.IndexId == id);
|
||||
if (itemNew is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item is not null)
|
||||
{
|
||||
lstUpdates.Add(itemNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstInserts.Add(itemNew);
|
||||
}
|
||||
lstSaves.Add(itemNew);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (lstInserts.Count > 0)
|
||||
if (lstSaves.Count > 0)
|
||||
{
|
||||
await SQLiteHelper.Instance.InsertAllAsync(lstInserts);
|
||||
}
|
||||
|
||||
if (lstUpdates.Count > 0)
|
||||
{
|
||||
await SQLiteHelper.Instance.UpdateAllAsync(lstUpdates);
|
||||
//Another save may have inserted these rows since the queue was drained.
|
||||
await SQLiteHelper.Instance.ReplaceAllAsync(lstSaves);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user