Skip to content

Commit 80f840a

Browse files
committed
1 parent a2413fd commit 80f840a

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

v2rayN/ServiceLib/Handler/ConfigHandler.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,20 @@ public static async Task<int> AddBatchServers(Config config, string strData, str
12961296
}
12971297
}
12981298

1299+
//Keep the last traffic statistics
1300+
if (lstOriSub != null)
1301+
{
1302+
var lstSub = await AppHandler.Instance.ProfileItems(subid);
1303+
foreach (var item in lstSub)
1304+
{
1305+
var existItem = lstOriSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == item.Remarks : CompareProfileItem(t, item, true));
1306+
if (existItem != null)
1307+
{
1308+
await StatisticsHandler.Instance.CloneServerStatItem(existItem.IndexId, item.IndexId);
1309+
}
1310+
}
1311+
}
1312+
12991313
return counter;
13001314
}
13011315

v2rayN/ServiceLib/Handler/StatisticsHandler.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ public async Task SaveTo()
6565
}
6666
}
6767

68+
public async Task CloneServerStatItem(string indexId, string toIndexId)
69+
{
70+
if (_lstServerStat == null)
71+
{
72+
return;
73+
}
74+
75+
var stat = _lstServerStat.FirstOrDefault(t => t.IndexId == indexId);
76+
if (stat == null)
77+
{
78+
return;
79+
}
80+
81+
var toStat = JsonUtils.DeepCopy(stat);
82+
toStat.IndexId = toIndexId;
83+
await SQLiteHelper.Instance.ReplaceAsync(toStat);
84+
_lstServerStat.Add(toStat);
85+
}
86+
6887
private async Task InitData()
6988
{
7089
await SQLiteHelper.Instance.ExecuteAsync($"delete from ServerStatItem where indexId not in ( select indexId from ProfileItem )");

0 commit comments

Comments
 (0)