| 45 | } |
| 46 | |
| 47 | void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate) |
| 48 | { |
| 49 | qDebug() << "Checking for updates."; |
| 50 | |
| 51 | // If the channel list hasn't loaded yet, load it and defer checking for updates until |
| 52 | // later. |
| 53 | if (!m_chanListLoaded) |
| 54 | { |
| 55 | qDebug() << "Channel list isn't loaded yet. Loading channel list and deferring update check."; |
| 56 | m_checkUpdateWaiting = true; |
| 57 | m_deferredUpdateChannel = updateChannel; |
| 58 | updateChanList(notifyNoUpdate); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | if (m_updateChecking) |
| 63 | { |
| 64 | qDebug() << "Ignoring update check request. Already checking for updates."; |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | // Find the desired channel within the channel list and get its repo URL. If if cannot be |
| 69 | // found, error. |
| 70 | QString stableUrl; |
| 71 | m_newRepoUrl = ""; |
| 72 | for (ChannelListEntry entry : m_channels) |
| 73 | { |
| 74 | qDebug() << "channelEntry = " << entry.id; |
| 75 | if(entry.id == "stable") { |
| 76 | stableUrl = entry.url; |
| 77 | } |
| 78 | if (entry.id == updateChannel) { |
| 79 | m_newRepoUrl = entry.url; |
| 80 | qDebug() << "is intended update channel: " << entry.id; |
| 81 | } |
| 82 | if (entry.id == m_currentChannel) { |
| 83 | m_currentRepoUrl = entry.url; |
| 84 | qDebug() << "is current update channel: " << entry.id; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | qDebug() << "m_repoUrl = " << m_newRepoUrl; |
| 89 | |
| 90 | if (m_newRepoUrl.isEmpty()) { |
| 91 | qWarning() << "m_repoUrl was empty. defaulting to 'stable': " << stableUrl; |
| 92 | m_newRepoUrl = stableUrl; |
| 93 | } |
| 94 | |
| 95 | // If nothing applies, error |
| 96 | if (m_newRepoUrl.isEmpty()) |
| 97 | { |
| 98 | qCritical() << "failed to select any update repository for: " << updateChannel; |
| 99 | emit updateCheckFailed(); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | m_updateChecking = true; |
| 104 | |