Skip to content

Commit 34ca164

Browse files
authored
Handle backwards compability for tl-install
1 parent 1af767d commit 34ca164

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

platform.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -263,50 +263,54 @@ def _extract_version_from_url(self, version_string: str) -> str:
263263

264264
def _install_tl_install(self, version: str) -> bool:
265265
"""
266-
Install tool-esp_install ONLY when necessary.
267-
266+
Install tool-esp_install ONLY when necessary
267+
and handles backwards compability for tl-install.
268+
268269
Args:
269270
version: Version string or URL to install
270-
271+
271272
Returns:
272273
bool: True if installation successful, False otherwise
273274
"""
274275
tl_install_path = os.path.join(self.packages_dir, tl_install_name)
275-
276+
old_tl_install_path = os.path.join(self.packages_dir, "tl-install")
277+
276278
try:
277-
# Remove old installation completely
279+
old_tl_install_exists = os.path.exists(old_tl_install_path)
280+
if old_tl_install_exists:
281+
# remove outdated tl-install
282+
safe_remove_directory(old_tl_install_path)
283+
278284
if os.path.exists(tl_install_path):
279285
logger.info(f"Removing old {tl_install_name} installation")
280286
safe_remove_directory(tl_install_path)
281287

282-
# Remove maybe old existing version of tl-install too
283-
old_tl_install_path = os.path.join(self.packages_dir, "tl-install")
284-
if os.path.exists(old_tl_install_path):
285-
safe_remove_directory(old_tl_install_path)
286-
287-
# Install new version
288288
logger.info(f"Installing {tl_install_name} version {version}")
289-
290-
# Set package configuration
291289
self.packages[tl_install_name]["optional"] = False
292290
self.packages[tl_install_name]["version"] = version
293-
294-
# Install via package manager
295291
pm.install(version)
296292

297-
# Verify installation
298293
if os.path.exists(os.path.join(tl_install_path, "package.json")):
299294
logger.info(f"{tl_install_name} successfully installed and verified")
300295
self.packages[tl_install_name]["optional"] = True
296+
297+
# Handle old tl-install to keep backwards compability
298+
if old_tl_install_exists:
299+
# Copy tool-esp_install content to tl-install location
300+
if safe_copy_directory(tl_install_path, old_tl_install_path):
301+
logger.info(f"Content copied from {tl_install_name} to old tl-install location")
302+
else:
303+
logger.warning(f"Failed to copy content to old tl-install location")
301304
return True
302305
else:
303306
logger.error(f"{tl_install_name} installation failed - package.json not found")
304307
return False
305-
308+
306309
except Exception as e:
307310
logger.error(f"Error installing {tl_install_name}: {e}")
308311
return False
309312

313+
310314
def _get_tool_paths(self, tool_name: str) -> Dict[str, str]:
311315
"""Get centralized path calculation for tools with caching."""
312316
if tool_name not in self._tools_cache:

0 commit comments

Comments
 (0)