fix(plugins): Fix 'local variable pluginInstaller referenced before assignment' error

- Remove redundant local import of pluginInstaller inside install_from_store function
- pluginInstaller is already imported at module level (line 20)
- The local import was creating a variable shadowing issue
- When the cleanup code path wasn't executed, pluginInstaller was referenced before assignment
- Fixes installation from store failing with variable reference error
This commit is contained in:
master3395
2026-01-26 03:41:14 +01:00
parent 666b1d4097
commit 6b65cf12d8

View File

@@ -1303,15 +1303,14 @@ def install_from_store(request, plugin_name):
else:
# Directory exists but no meta.xml - likely incomplete/uninstalled
# Try to clean it up first using pluginInstaller.removeFiles which handles permissions
# pluginInstaller is already imported at module level, no need to import again
try:
from pluginInstaller.pluginInstaller import pluginInstaller
pluginInstaller.removeFiles(plugin_name)
logging.writeToFile(f'Cleaned up incomplete plugin directory: {plugin_name}')
except Exception as e:
logging.writeToFile(f'Warning: Could not clean up incomplete directory: {str(e)}')
# Try fallback: use system rm -rf
try:
import subprocess
result = subprocess.run(['rm', '-rf', pluginInstalled], capture_output=True, text=True, timeout=30)
if result.returncode == 0:
logging.writeToFile(f'Cleaned up incomplete plugin directory using rm -rf: {plugin_name}')