| 1466 | } |
| 1467 | |
| 1468 | bool Backend::shouldOfferAutoUpdates() const |
| 1469 | { |
| 1470 | // Only relevant inside a Flatpak |
| 1471 | if (!QFile::exists("/.flatpak-info")) |
| 1472 | return false; |
| 1473 | |
| 1474 | if (!flatpakRepoDescriptorHasGpgKey()) |
| 1475 | return false; |
| 1476 | |
| 1477 | // Check if user already dismissed |
| 1478 | QString configPath = crConfigDir() + "/config.json"; |
| 1479 | QFile f(configPath); |
| 1480 | if (f.open(QIODevice::ReadOnly)) { |
| 1481 | QJsonDocument doc = QJsonDocument::fromJson(f.readAll()); |
| 1482 | f.close(); |
| 1483 | if (doc.isObject() && doc.object().value("auto_update_prompted").toBool()) |
| 1484 | return false; |
| 1485 | } |
| 1486 | |
| 1487 | // Check if a repo is already configured for this app |
| 1488 | QProcess proc; |
| 1489 | proc.start("flatpak-spawn", {"--host", "flatpak", "remote-list", "--user", "--columns=name,url"}); |
| 1490 | proc.waitForFinished(5000); |
| 1491 | QString output = proc.readAllStandardOutput(); |
| 1492 | if (output.contains("cloudredirect") || output.contains("CloudRedirect-Unified")) |
| 1493 | return false; |
| 1494 | |
| 1495 | return true; |
| 1496 | } |
| 1497 | |
| 1498 | void Backend::enableAutoUpdates() |
| 1499 | { |
nothing calls this directly
no test coverage detected