Skip to content

Commit 86bebab

Browse files
committed
[Plugin Installer] Fix #8111. Better repository error handling.
1 parent fd2b221 commit 86bebab

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

python/pyplugin_installer/installer_data.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,15 @@ def xmlDownloaded(self):
403403
reply = self.sender()
404404
reposName = reply.property( 'reposName' )
405405
if reply.error() != QNetworkReply.NoError: # fetching failed
406-
self.mRepositories[reposName]["state"] = 3
407-
self.mRepositories[reposName]["error"] = str(reply.error())
406+
self.mRepositories[reposName]["state"] = 3
407+
self.mRepositories[reposName]["error"] = reply.errorString()
408+
if reply.error() == QNetworkReply.OperationCanceledError:
409+
self.mRepositories[reposName]["error"] += "\n\n" + QCoreApplication.translate("QgsPluginInstaller", "If you haven't cancelled the download manually, it might be caused by a timeout. In this case consider increasing the connection timeout value in QGIS options.")
410+
elif reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
411+
self.mRepositories[reposName]["state"] = 3
412+
self.mRepositories[reposName]["error"] = QCoreApplication.translate("QgsPluginInstaller", "Status code:") + " %d %s" % (
413+
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute),
414+
reply.attribute(QNetworkRequest.HttpReasonPhraseAttribute))
408415
else:
409416
reposXML = QDomDocument()
410417
reposXML.setContent(reply.readAll())
@@ -461,8 +468,10 @@ def xmlDownloaded(self):
461468
if isCompatible(QGis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
462469
#add the plugin to the cache
463470
plugins.addFromRepository(plugin)
464-
# set state=2, even if the repo is empty
465-
self.mRepositories[reposName]["state"] = 2
471+
self.mRepositories[reposName]["state"] = 2
472+
else:
473+
self.mRepositories[reposName]["state"] = 3
474+
self.mRepositories[reposName]["error"] = QCoreApplication.translate("QgsPluginInstaller", "Server response doesn't contain plugin metatada.")
466475

467476
self.repositoryFetched.emit( reposName )
468477

python/pyplugin_installer/qgsplugininstallerinstallingdialog.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,15 @@ def readProgress(self, done, total):
7979
self.progressBar.setMaximum(total)
8080
self.progressBar.setValue(done)
8181

82+
8283
# ----------------------------------------- #
8384
def requestFinished(self):
8485
reply = self.sender()
8586
self.buttonBox.setEnabled(False)
8687
if reply.error() != QNetworkReply.NoError:
8788
self.mResult = reply.errorString()
89+
if reply.error() == QNetworkReply.OperationCanceledError:
90+
self.mResult += "<br/><br/>" + QCoreApplication.translate("QgsPluginInstaller", "If you haven't cancelled the download manually, it might be caused by a timeout. In this case consider increasing the connection timeout value in QGIS options.")
8891
self.reject()
8992
del reply
9093
return

0 commit comments

Comments
 (0)