From 9af5e7cfa07a9b5c4574a7f9ddec3b73e8d39e8b Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Tue, 17 Oct 2023 21:27:53 +0200 Subject: [PATCH] fix(pip): don't delete server directory on installation error --- st3/lsp_utils/server_pip_resource.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/st3/lsp_utils/server_pip_resource.py b/st3/lsp_utils/server_pip_resource.py index 550dd41..0ecd638 100644 --- a/st3/lsp_utils/server_pip_resource.py +++ b/st3/lsp_utils/server_pip_resource.py @@ -67,6 +67,9 @@ def python_version(self) -> str: def binary_path(self) -> str: return self.server_binary() + def get_status(self) -> int: + return self._status + def needs_installation(self) -> bool: if not path.exists(self.server_binary()) or not path.exists(self.pip_binary()): return True @@ -100,10 +103,7 @@ def install_or_update(self) -> None: self.run(self.pip_binary(), 'install', '-r', dest_requirements_txt_path, '--disable-pip-version-check') with open(self.python_version(), 'w') as f: f.write(self.run(self._python_binary, '--version')) - except Exception: - shutil.rmtree(self.basedir(), ignore_errors=True) - raise + except Exception as error: + self._status = ServerStatus.ERROR + raise Exception('Error installing the server:\n{}'.format(error)) self._status = ServerStatus.READY - - def get_status(self) -> int: - return self._status