UI: Statistics: Fix traffic updating for new app, after it was blocked.

This commit is contained in:
Nodir Temirkhodjaev 2021-05-29 15:17:03 +03:00
parent c8ef46ee4b
commit 09413876e4
2 changed files with 7 additions and 7 deletions

View File

@ -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);
}

View File

@ -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);