From 09413876e4937e9c1e89a5c45f9226a91210ed38 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sat, 29 May 2021 15:17:03 +0300 Subject: [PATCH] UI: Statistics: Fix traffic updating for new app, after it was blocked. --- src/ui/stat/statmanager.cpp | 12 ++++++------ src/ui/stat/statmanager.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ui/stat/statmanager.cpp b/src/ui/stat/statmanager.cpp index 54fe2ab3..da766e74 100644 --- a/src/ui/stat/statmanager.cpp +++ b/src/ui/stat/statmanager.cpp @@ -348,7 +348,7 @@ bool StatManager::logBlockedIp(const LogEntryBlockedIp &entry, qint64 unixTime) bool ok = false; sqliteDb()->beginTransaction(); - const qint64 appId = getOrCreateAppId(entry.path(), unixTime, true); + const qint64 appId = getOrCreateAppId(entry.path(), unixTime); if (appId != INVALID_APP_ID) { ok = createConnBlock(entry, unixTime, appId); } @@ -492,7 +492,7 @@ qint64 StatManager::createAppId(const QString &appPath, qint64 unixTime) return INVALID_APP_ID; } -qint64 StatManager::getOrCreateAppId(const QString &appPath, qint64 unixTime, bool blocked) +qint64 StatManager::getOrCreateAppId(const QString &appPath, qint64 unixTime) { qint64 appId = getCachedAppId(appPath); if (appId == INVALID_APP_ID) { @@ -506,10 +506,6 @@ qint64 StatManager::getOrCreateAppId(const QString &appPath, qint64 unixTime, bo Q_ASSERT(appId != INVALID_APP_ID); - if (!blocked && !hasAppTraf(appId)) { - emit appCreated(appId, appPath); - } - addCachedAppId(appPath, appId); } return appId; @@ -593,6 +589,10 @@ void StatManager::logTrafBytes(const QStmtList &insertStmtList, const QStmtList Q_ASSERT(appId != INVALID_APP_ID); if (m_isActivePeriod) { + if (!hasAppTraf(appId)) { + emit appCreated(appId, appPath); + } + // Update or insert app bytes updateTrafficList(insertStmtList, updateStmtList, inBytes, outBytes, appId); } diff --git a/src/ui/stat/statmanager.h b/src/ui/stat/statmanager.h index e44ab8ce..190869e8 100644 --- a/src/ui/stat/statmanager.h +++ b/src/ui/stat/statmanager.h @@ -114,7 +114,7 @@ private: qint64 getAppId(const QString &appPath); qint64 createAppId(const QString &appPath, qint64 unixTime); - qint64 getOrCreateAppId(const QString &appPath, qint64 unixTime = 0, bool blocked = false); + qint64 getOrCreateAppId(const QString &appPath, qint64 unixTime = 0); bool deleteAppId(qint64 appId); void deleteOldTraffic(qint32 trafHour);