Skip to content

Commit 435ca54

Browse files
committed
Fix crash in bi-daily update check
Reload feed before checking for updates and validate download URL.
1 parent f0f6bfe commit 435ca54

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/updater.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,34 @@ void Updater::checkUpdatesOnStart()
178178

179179
mDailyCheck->setInterval(12h);
180180
connect(mDailyCheck.get(), &QTimer::timeout, this, [this] {
181-
auto updates = feed->getUpdates(dblsqd::Release::getCurrentRelease());
182-
qWarning() << "Bi-daily check for updates:" << updates.size() << "update(s) available";
183-
if (updates.isEmpty()) {
184-
return;
185-
} else if (!updateAutomatically()) {
186-
emit signal_updateAvailable(updates.size());
187-
} else {
188-
feed->downloadRelease(updates.first());
189-
}
181+
// Reload the feed to get fresh data before checking for updates
182+
// Use single-shot connections to avoid multiple handlers accumulating
183+
KDToolBox::connectSingleShot(feed, &dblsqd::Feed::ready, this, [this]() {
184+
auto updates = feed->getUpdates(dblsqd::Release::getCurrentRelease());
185+
qWarning() << "Bi-daily check for updates:" << updates.size() << "update(s) available";
186+
if (updates.isEmpty()) {
187+
return;
188+
}
189+
190+
if (!updateAutomatically()) {
191+
emit signal_updateAvailable(updates.size());
192+
return;
193+
}
194+
195+
// Validate the release has a valid download URL before attempting download
196+
const auto& release = updates.first();
197+
const QUrl downloadUrl = release.getDownloadUrl();
198+
if (!downloadUrl.isValid() || downloadUrl.isEmpty()) {
199+
qWarning() << "Bi-daily update check: invalid download URL for release" << release.getVersion();
200+
return;
201+
}
202+
203+
feed->downloadRelease(release);
204+
});
205+
KDToolBox::connectSingleShot(feed, &dblsqd::Feed::loadError, this, [](const QString& error) {
206+
qWarning() << "Bi-daily update check: failed to load feed:" << error;
207+
});
208+
feed->load();
190209
});
191210
mDailyCheck->start();
192211
}

0 commit comments

Comments
 (0)