MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / checkForFlatpakUpdate

Method checkForFlatpakUpdate

ui-linux/src/backend.cpp:1570–1612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1568}
1569
1570void Backend::checkForFlatpakUpdate()
1571{
1572 // Only relevant inside or alongside a Flatpak install
1573 QString remotes = runFlatpakHostCommand({"remote-list", "--user", "--columns=name"});
1574 if (!remotes.contains("cloudredirect"))
1575 return;
1576
1577 // Get remote version and compare against running version
1578 QString info = runFlatpakHostCommand({"remote-info", "--user", "cloudredirect", "org.cloudredirect.CloudRedirect"});
1579 QString remoteVersion;
1580 for (const QString &line : info.split('\n')) {
1581 if (line.trimmed().startsWith("Version:")) {
1582 remoteVersion = line.mid(line.indexOf(':') + 1).trimmed();
1583 break;
1584 }
1585 }
1586
1587 if (remoteVersion.isEmpty())
1588 return;
1589
1590 // Compare versions: only notify if remote is strictly newer
1591 QString current = QCoreApplication::applicationVersion();
1592 auto parseVer = [](const QString &v) -> QList<int> {
1593 // Strip prerelease suffix (e.g. "-TEST4") for comparison
1594 QString base = v.section('-', 0, 0);
1595 QList<int> parts;
1596 for (const QString &p : base.split('.'))
1597 parts.append(p.toInt());
1598 while (parts.size() < 3) parts.append(0);
1599 return parts;
1600 };
1601
1602 QList<int> rv = parseVer(remoteVersion);
1603 QList<int> cv = parseVer(current);
1604 bool remoteNewer = false;
1605 for (int i = 0; i < 3; ++i) {
1606 if (rv[i] > cv[i]) { remoteNewer = true; break; }
1607 if (rv[i] < cv[i]) break;
1608 }
1609
1610 if (remoteNewer)
1611 emit flatpakUpdateAvailable();
1612}
1613
1614void Backend::applyFlatpakUpdate()
1615{

Callers

nothing calls this directly

Calls 2

runFlatpakHostCommandFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected