Skip to content

Commit c17f5bd

Browse files
author
Michael Whapples
committed
Fix issue where errors may be reported multiple times.
1 parent 2017758 commit c17f5bd

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

src/convert2ebrl/main_window.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def on_update_available(v):
2626
QDesktopServices.openUrl(QUrl(make_qurl(download_site, "download.html")))
2727
update_checker.updateAvailable.connect(on_update_available)
2828
update_checker.noUpdateAvailable.connect(lambda: QMessageBox.information(self, "No updates", "You are running the latest version of the software."))
29+
update_checker.errorOccurred.connect(lambda x: QMessageBox.warning(self, "Unable to check for updates.", "There was a problem whilst checking for updates, please try again later."))
2930
update_check_action = QAction("Check for updates", self)
3031
download_url = make_qurl(download_site, "metadata.properties")
3132
update_check_action.triggered.connect(lambda _: update_checker.check_for_update(download_url))

src/convert2ebrl/update_checker.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def check_for_update(self, update_url: QUrl):
3030
@Slot()
3131
def on_ready_read(self):
3232
if self.reply:
33-
if self.reply.error() == QNetworkReply.NetworkError.NoError:
33+
if self.reply.error() == QNetworkReply.NetworkError.NoError and self.reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) == 200:
3434
response_text = str(self.reply.readAll(), "utf-8")
3535
if m := _APP_VERSION_RE.search(response_text):
3636
if Version(QCoreApplication.applicationVersion()) < Version(m.group(1)):
@@ -39,10 +39,6 @@ def on_ready_read(self):
3939
self.noUpdateAvailable.emit()
4040
else:
4141
self.errorOccurred.emit("Unable to find latest version")
42-
else:
43-
self.errorOccurred.emit(self.reply.errorString())
44-
else:
45-
self.errorOccurred.emit("Unknown error")
4642
@Slot()
4743
def on_finished(self):
4844
if self.reply:

0 commit comments

Comments
 (0)