Plugin install: pass absolute zip path to avoid cwd races; extract always uses given path

This commit is contained in:
master3395
2026-03-06 20:26:15 +01:00
committed by KraoESPfan1n
parent 24467035a9
commit d2ad06aa4e
2 changed files with 27 additions and 30 deletions

View File

@@ -60,13 +60,17 @@ class pluginInstaller:
### Functions Related to plugin installation.
@staticmethod
def extractPlugin(pluginName):
def extractPlugin(pluginName, zip_path=None):
"""
Extract plugin zip so that all files end up in /usr/local/CyberCP/pluginName/.
Handles zips with: (1) top-level folder pluginName/, (2) top-level folder with
another name (e.g. repo-main/), or (3) files at root (no top-level folder).
If zip_path is given (absolute path), use it; otherwise use pluginName + '.zip' in cwd.
"""
pathToPlugin = pluginName + '.zip'
if zip_path is not None:
pathToPlugin = os.path.abspath(zip_path)
else:
pathToPlugin = os.path.abspath(pluginName + '.zip')
if not os.path.exists(pathToPlugin):
raise Exception(f"Plugin zip not found: {pathToPlugin}")
pluginPath = '/usr/local/CyberCP/' + pluginName
@@ -245,12 +249,12 @@ class pluginInstaller:
@staticmethod
def installPlugin(pluginName):
def installPlugin(pluginName, zip_path=None):
try:
##
pluginInstaller.stdOut('Extracting plugin..')
pluginInstaller.extractPlugin(pluginName)
pluginInstaller.extractPlugin(pluginName, zip_path=zip_path)
pluginInstaller.stdOut('Plugin extracted.')
##