From f669c3fb0d584b44e316c7014419623079c9feb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 27 Jan 2021 18:56:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20backup:=20fix=20plugin=20repo=20?= =?UTF-8?q?access=20on=20cli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were trying to fetch the repo url from the settings. However, due to the settings overlays from other plugins not being available when operating in a CLI environment, the repository URL was unset and thus nothing was fetched. This is now fixed by falling back to the default repo URL from the pluginmanager, which has been extracted into a constant for that reason. Fixes #3883 --- src/octoprint/plugins/backup/__init__.py | 8 +++++--- src/octoprint/plugins/pluginmanager/__init__.py | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 366e03883..bd3e73ab8 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -49,6 +49,7 @@ import requests import sarge from flask_babel import gettext +from octoprint.plugins.pluginmanager import DEFAULT_PLUGIN_REPOSITORY from octoprint.settings import valid_boolean_trues from octoprint.util.text import sanitize @@ -1118,10 +1119,11 @@ class BackupPlugin( basedir = settings._basedir cls._clean_dir_backup(basedir, on_log_progress=on_log_progress) - plugin_repo = {} repo_url = settings.global_get(["plugins", "pluginmanager", "repository"]) - if repo_url: - plugin_repo = cls._get_plugin_repository_data(repo_url) + if not repo_url: + repo_url = DEFAULT_PLUGIN_REPOSITORY + + plugin_repo = cls._get_plugin_repository_data(repo_url) if callable(on_restore_start): on_restore_start(path) diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 15cb8e013..cdf71ff15 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -56,6 +56,9 @@ except ImportError: _DATA_FORMAT_VERSION = "v3" +DEFAULT_PLUGIN_REPOSITORY = "https://plugins.octoprint.org/plugins.json" +DEFAULT_PLUGIN_NOTICES = "https://plugins.octoprint.org/notices.json" + def map_repository_entry(entry): if not isinstance(entry, dict): @@ -275,9 +278,9 @@ class PluginManagerPlugin( def get_settings_defaults(self): return { - "repository": "https://plugins.octoprint.org/plugins.json", + "repository": DEFAULT_PLUGIN_REPOSITORY, "repository_ttl": 24 * 60, - "notices": "https://plugins.octoprint.org/notices.json", + "notices": DEFAULT_PLUGIN_NOTICES, "notices_ttl": 6 * 60, "pip_args": None, "pip_force_user": False,