From 15f7c8d2c8b58dbd96f39c346b7ddc9d6ab14f87 Mon Sep 17 00:00:00 2001 From: "Josh.5" Date: Wed, 27 Dec 2023 11:54:31 +1300 Subject: [PATCH] Prevent installation of a plugin if the destination is a git repo --- unmanic/libs/plugins.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unmanic/libs/plugins.py b/unmanic/libs/plugins.py index 591a78b5..1012d542 100644 --- a/unmanic/libs/plugins.py +++ b/unmanic/libs/plugins.py @@ -460,10 +460,14 @@ def install_plugin(self, zip_file, plugin_id=None): plugin_id = plugin_info.get('id') # Create plugin destination directory based on plugin ID plugin_directory = self.get_plugin_path(plugin_id) + # Prevent installation if destination has a git repository. This plugin is probably under development + self._log(os.path.join(str(plugin_directory), '.git')) + if os.path.exists(os.path.join(str(plugin_directory), '.git')): + raise Exception("Plugin directory contains a git repository. Uninstall this source version before installing.") # Extract zip file contents self._log("Extracting plugin to '{}'".format(plugin_directory), level='debug') with zipfile.ZipFile(zip_file, "r") as zip_ref: - zip_ref.extractall(plugin_directory) + zip_ref.extractall(str(plugin_directory)) # Return installed plugin info return self.get_plugin_info(plugin_id)