Skip to content
Permalink
Browse files

[plugins] When a user clicks the "Reload all repositories" button

manually in the plugin manager, then force a reload of the repositories
and don't rely on cached copies of the repo manifest

Otherwise it's not possible to force a refresh on certain types of
plugin repositories where it's not possible to modify the Cache-Control
attribute of the repo

Note that to avoid unnecessary server load, we still use cached
copies during startup and by default. It's only when a user explicitly
hits the "Reload all repositories" button that we force a non-cached
fetch.

Fixes #34351

(cherry picked from commit edfc691)
  • Loading branch information
nyalldawson committed May 27, 2020
1 parent 3666a79 commit 30cd6f0005a78b63bc36e617bc64e12987baeb44
Showing with 4 additions and 2 deletions.
  1. +1 −1 python/pyplugin_installer/installer.py
  2. +3 −1 python/pyplugin_installer/installer_data.py
@@ -119,7 +119,7 @@ def fetchAvailablePlugins(self, reloadMode):

for key in repositories.allEnabled():
if reloadMode or repositories.all()[key]["state"] == 3: # if state = 3 (error or not fetched yet), try to fetch once again
repositories.requestFetching(key)
repositories.requestFetching(key, force_reload=reloadMode)

if repositories.fetchingInProgress():
fetchDlg = QgsPluginInstallerFetchingDialog(iface.mainWindow())
@@ -314,7 +314,7 @@ def load(self):
settings.endGroup()

# ----------------------------------------- #
def requestFetching(self, key, url=None, redirectionCounter=0):
def requestFetching(self, key, url=None, redirectionCounter=0, force_reload=False):
""" start fetching the repository given by key """
self.mRepositories[key]["state"] = 1
if not url:
@@ -325,6 +325,8 @@ def requestFetching(self, key, url=None, redirectionCounter=0):
self.mRepositories[key]["QRequest"] = QNetworkRequest(url)
self.mRepositories[key]["QRequest"].setAttribute(QNetworkRequest.Attribute(QgsNetworkRequestParameters.AttributeInitiatorClass), "Relay")
self.mRepositories[key]["QRequest"].setAttribute(QNetworkRequest.FollowRedirectsAttribute, True)
if force_reload:
self.mRepositories[key]["QRequest"].setAttribute(QNetworkRequest.CacheLoadControlAttribute, QNetworkRequest.AlwaysNetwork)
authcfg = self.mRepositories[key]["authcfg"]
if authcfg and isinstance(authcfg, str):
if not QgsApplication.authManager().updateNetworkRequest(

0 comments on commit 30cd6f0

Please sign in to comment.
You can’t perform that action at this time.