mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Fix version checking
This commit is contained in:
@ -11,8 +11,6 @@
|
|||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#define PREVIOUS_VERSION_TESTING "6.0.0"
|
|
||||||
|
|
||||||
HttpVersionChecker::HttpVersionChecker()
|
HttpVersionChecker::HttpVersionChecker()
|
||||||
: HttpWorker("https://raw.githubusercontent.com/YACReader/yacreader/master/VERSION", DEFAULT_USER_AGENT)
|
: HttpWorker("https://raw.githubusercontent.com/YACReader/yacreader/master/VERSION", DEFAULT_USER_AGENT)
|
||||||
{
|
{
|
||||||
@ -26,12 +24,17 @@ void HttpVersionChecker::checkNewVersion(const QByteArray &data)
|
|||||||
|
|
||||||
bool HttpVersionChecker::checkNewVersion(QString sourceContent)
|
bool HttpVersionChecker::checkNewVersion(QString sourceContent)
|
||||||
{
|
{
|
||||||
#ifdef QT_DEBUG
|
|
||||||
const auto currentVersion = QVersionNumber::fromString(PREVIOUS_VERSION_TESTING);
|
|
||||||
#else
|
|
||||||
const auto currentVersion = QVersionNumber::fromString(QString::fromLatin1(VERSION));
|
const auto currentVersion = QVersionNumber::fromString(QString::fromLatin1(VERSION));
|
||||||
#endif
|
const auto trimmedSourceContent = sourceContent.trimmed();
|
||||||
const auto latestVersion = QVersionNumber::fromString(sourceContent.trimmed());
|
qsizetype suffixIndex = 0;
|
||||||
|
const auto latestVersion = QVersionNumber::fromString(trimmedSourceContent, &suffixIndex);
|
||||||
|
|
||||||
|
if (trimmedSourceContent.isEmpty() ||
|
||||||
|
suffixIndex != trimmedSourceContent.size() ||
|
||||||
|
latestVersion.segments().size() != 3) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!currentVersion.isNull() && !latestVersion.isNull() && QVersionNumber::compare(latestVersion, currentVersion) > 0) {
|
if (!currentVersion.isNull() && !latestVersion.isNull() && QVersionNumber::compare(latestVersion, currentVersion) > 0) {
|
||||||
emit newVersionDetected();
|
emit newVersionDetected();
|
||||||
|
|||||||
Reference in New Issue
Block a user