fix: wrong InstalledTime for application

fallback to pre-value when it's valid.
This commit is contained in:
Ye ShanShan 2024-03-18 17:06:55 +08:00 committed by yeshanshan
parent f3134f7609
commit df502f8293

View File

@ -107,16 +107,17 @@ ApplicationService::ApplicationService(DesktopFile source,
qWarning() << "failed to set InstalledTime for" << appId << "at first launch"; qWarning() << "failed to set InstalledTime for" << appId << "at first launch";
} }
} else { } else {
if (value.isNull()) {
auto newInstalledTime = QDateTime::currentMSecsSinceEpoch(); auto newInstalledTime = QDateTime::currentMSecsSinceEpoch();
auto ret = value.isNull() ? if (!storagePtr->createApplicationValue(appId, ApplicationPropertiesGroup, InstalledTime, newInstalledTime)) {
storagePtr->createApplicationValue(appId, ApplicationPropertiesGroup, InstalledTime, newInstalledTime) :
true;
if (!ret) {
m_installedTime = -1; m_installedTime = -1;
qWarning() << "failed to set InstalledTime for new apps:" << appId; qWarning() << "failed to set InstalledTime for new apps:" << appId;
} else { } else {
m_installedTime = newInstalledTime; m_installedTime = newInstalledTime;
} }
} else {
m_installedTime = value.toLongLong();
}
} }
value = storagePtr->readApplicationValue(appId, ApplicationPropertiesGroup, LastLaunchedTime); value = storagePtr->readApplicationValue(appId, ApplicationPropertiesGroup, LastLaunchedTime);