fix: Check for errors before reading version string

This commit is contained in:
Nick Bolton
2024-10-15 05:47:37 +01:00
committed by Chris Rizzitello
parent 23c4cadf17
commit 87b4e3b7fe

View File

@ -57,10 +57,23 @@ void VersionChecker::checkLatest() const {
}
void VersionChecker::replyFinished(QNetworkReply *reply) {
auto newestVersion = QString(reply->readAll());
const auto httpStatus =
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (reply->error() != QNetworkReply::NoError) {
qWarning(
"version check server error: %s", qPrintable(reply->errorString()));
qWarning("error checking for updates, http status: %d", httpStatus);
return;
}
qInfo("version check server success, http status: %d", httpStatus);
const auto newestVersion = QString(reply->readAll());
qDebug("version check response: %s", qPrintable(newestVersion));
if (!newestVersion.isEmpty() &&
compareVersions(DESKFLOW_VERSION, newestVersion) > 0) {
qDebug("update found: %s", qPrintable(newestVersion));
qDebug("update found");
emit updateFound(newestVersion);
} else {
qDebug("no updates found");