Do not accept "lastSeen" timestamps older or equal to the UNIX epoch

The UNIX epoch seems to be the "null-value" provided by Syncthing's API
when there's no "lastSeen" timestamp, e.g. when it is the own device.
This commit is contained in:
Martchus 2021-02-12 17:55:38 +01:00
parent bdf00a9889
commit 1cfd067abd
1 changed files with 2 additions and 1 deletions

View File

@ -1202,7 +1202,8 @@ void SyncthingConnection::readDeviceStatistics()
const QJsonObject devObj(replyObj.value(devInfo.id).toObject());
if (!devObj.isEmpty()) {
try {
devInfo.lastSeen = DateTime::fromIsoStringLocal(devObj.value(QLatin1String("lastSeen")).toString().toUtf8().data());
const auto [localTime, utcOffset] = DateTime::fromIsoString(devObj.value(QLatin1String("lastSeen")).toString().toUtf8().data());
devInfo.lastSeen = (localTime - utcOffset) > DateTime::unixEpochStart() ? localTime : DateTime();
emit devStatusChanged(devInfo, index);
} catch (const ConversionException &) {
devInfo.lastSeen = DateTime();