From df502f829321eaf830d422fea0e04d89ad058ba3 Mon Sep 17 00:00:00 2001 From: Ye ShanShan Date: Mon, 18 Mar 2024 17:06:55 +0800 Subject: [PATCH] fix: wrong InstalledTime for application fallback to pre-value when it's valid. --- src/dbus/applicationservice.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/dbus/applicationservice.cpp b/src/dbus/applicationservice.cpp index 279b883..8abc1e4 100644 --- a/src/dbus/applicationservice.cpp +++ b/src/dbus/applicationservice.cpp @@ -107,15 +107,16 @@ ApplicationService::ApplicationService(DesktopFile source, qWarning() << "failed to set InstalledTime for" << appId << "at first launch"; } } else { - auto newInstalledTime = QDateTime::currentMSecsSinceEpoch(); - auto ret = value.isNull() ? - storagePtr->createApplicationValue(appId, ApplicationPropertiesGroup, InstalledTime, newInstalledTime) : - true; - if (!ret) { - m_installedTime = -1; - qWarning() << "failed to set InstalledTime for new apps:" << appId; + if (value.isNull()) { + auto newInstalledTime = QDateTime::currentMSecsSinceEpoch(); + if (!storagePtr->createApplicationValue(appId, ApplicationPropertiesGroup, InstalledTime, newInstalledTime)) { + m_installedTime = -1; + qWarning() << "failed to set InstalledTime for new apps:" << appId; + } else { + m_installedTime = newInstalledTime; + } } else { - m_installedTime = newInstalledTime; + m_installedTime = value.toLongLong(); } }