Do not ASSERT in booking reader if format is NOT compatibel

See https://discordapp.com/channels/539048679160676382/568904623151382546/582299692352929793
This commit is contained in:
Klaus Basan
2019-05-26 23:32:59 +02:00
parent cb70e1e68b
commit bcb0f84592

View File

@@ -16,6 +16,7 @@
#include "blackmisc/network/url.h"
#include "blackmisc/network/user.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/verify.h"
#include <QByteArray>
#include <QDateTime>
@@ -99,15 +100,30 @@ namespace BlackCore
const QString xmlData = nwReply->readAll();
nwReply->close(); // close asap
if (xmlData.isEmpty() || !xmlData.contains("<bookings>", Qt::CaseInsensitive))
{
CLogMessage(this).warning(u"Reading bookings wrong XML format for '%1'") << nwReply->url().toString();
m_failures++;
emit this->dataRead(CEntityFlags::BookingEntity, CEntityFlags::ReadFailed, 0);
return;
}
QDomDocument doc;
QDateTime updateTimestamp = QDateTime::currentDateTimeUtc(); // default
if (doc.setContent(xmlData))
{
const QDomNode timestamp = doc.elementsByTagName("timestamp").at(0);
const QString ts = timestamp.toElement().text().trimmed();
Q_ASSERT(!ts.isEmpty());
BLACK_AUDIT_X(!ts.isEmpty(), Q_FUNC_INFO, "Wrong timestamp format");
if (!ts.isEmpty())
if (ts.isEmpty())
{
CLogMessage(this).warning(u"Reading bookings wrong XML timestamp format for '%1'") << nwReply->url().toString();
m_failures++;
emit this->dataRead(CEntityFlags::BookingEntity, CEntityFlags::ReadFailed, 0);
return;
}
else
{
// normally the timestamp is always updated from backend
// if this changes in the future we're prepared