Skip to content

Commit 42d7325

Browse files
committed
fix(updater): prefer versions with 3 digits rather than 2
Signed-off-by: so5iso4ka <so5iso4ka@icloud.com>
1 parent 92a592a commit 42d7325

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

launcher/Version.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Version::Version(QString str) : m_string(std::move(str))
4343

4444
bool Version::operator<(const Version& other) const
4545
{
46+
// prefer x.y.z over x.y
47+
if (versionDigitsNumber() == 3 && other.versionDigitsNumber() == 2) return false;
48+
4649
VERSION_OPERATOR(sec1 < sec2)
4750

4851
return false;
@@ -57,6 +60,24 @@ bool Version::operator!=(const Version& other) const
5760
{
5861
return !operator==(other);
5962
}
63+
64+
int Version::versionDigitsNumber() const
65+
{
66+
int num = 0;
67+
for (const auto& sec : m_sections) {
68+
if (!sec.isPreRelease() && !sec.isAppendix()) {
69+
if (sec.m_fullString == sec.m_stringPart) {
70+
continue;
71+
}
72+
++num;
73+
}
74+
else {
75+
break;
76+
}
77+
}
78+
return num;
79+
}
80+
6081
bool Version::operator<=(const Version& other) const
6182
{
6283
return *this < other || *this == other;

launcher/Version.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class Version {
6161
friend QDebug operator<<(QDebug debug, const Version& v);
6262

6363
private:
64+
int versionDigitsNumber() const;
65+
6466
struct Section {
6567
explicit Section(QString fullString) : m_fullString(std::move(fullString))
6668
{

0 commit comments

Comments
 (0)