File tree Expand file tree Collapse file tree
app/src/main/java/io/nekohasekai/sagernet Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ class TrafficLooper
3131 val item = idMap[ent.id] ? : return @forEach
3232 ent.rx = item.rx
3333 ent.tx = item.tx
34- ProfileManager .updateProfile (ent) // update DB
34+ ProfileManager .updateTraffic (ent.id, ent.rx, ent.tx)
3535 traffic[ent.id] = TrafficData (
3636 id = ent.id,
3737 rx = ent.rx,
@@ -67,7 +67,7 @@ class TrafficLooper
6767 it.rx = rx
6868 it.tx = tx
6969 runOnDefaultDispatcher {
70- ProfileManager .updateProfile (it) // update DB
70+ ProfileManager .updateTraffic (it.id, it.rx, it.tx)
7171 }
7272 }
7373 }
@@ -184,4 +184,4 @@ class TrafficLooper
184184 delay(delayMs)
185185 }
186186 }
187- }
187+ }
Original file line number Diff line number Diff line change @@ -97,6 +97,10 @@ object ProfileManager {
9797 }
9898 }
9999
100+ suspend fun updateTraffic (profileId : Long , rx : Long , tx : Long ) {
101+ SagerDatabase .proxyDao.updateTraffic(profileId, rx, tx)
102+ }
103+
100104 suspend fun deleteProfile2 (groupId : Long , profileId : Long ) {
101105 if (SagerDatabase .proxyDao.deleteById(profileId) == 0 ) return
102106 if (DataStore .selectedProxy == profileId) {
Original file line number Diff line number Diff line change @@ -605,6 +605,9 @@ data class ProxyEntity(
605605 @Update
606606 fun updateProxy (proxies : List <ProxyEntity >): Int
607607
608+ @Query(" UPDATE proxy_entities SET rx = :rx, tx = :tx WHERE id = :proxyId" )
609+ fun updateTraffic (proxyId : Long , rx : Long , tx : Long ): Int
610+
608611 @Insert
609612 fun addProxy (proxy : ProxyEntity ): Long
610613
You can’t perform that action at this time.
0 commit comments