From 0df55def29fb992751010f6b8a707699f230ff37 Mon Sep 17 00:00:00 2001 From: melMass Date: Sat, 22 Jul 2023 18:19:32 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E2=9C=A8=20also=20try=20to=20copy=20web?= =?UTF-8?q?=20if=20symlink=20fails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 89fd22c..2423e2b 100644 --- a/__init__.py +++ b/__init__.py @@ -94,9 +94,28 @@ web_mtb = web_extensions_root / "mtb" if web_mtb.exists(): log.debug(f"Web extensions folder found at {web_mtb}") + if not os.path.islink(web_mtb.as_posix()): + log.warn( + f"Web extensions folder at {web_mtb} is not a symlink, if updating please delete it before" + ) + + elif web_extensions_root.exists(): + web_tgt = here / "web" try: - os.symlink((here / "web"), web_mtb.as_posix()) + os.symlink(web_tgt.as_posix(), web_mtb.as_posix()) + except OSError: + log.warn(f"Failed to create symlink to {web_mtb}, trying to copy it") + try: + import shutil + + shutil.copytree(web_tgt, web_mtb) + log.info(f"Successfully copied {web_tgt} to {web_mtb}") + except Exception: + log.warn( + f"Failed to symlink and copy {web_tgt} to {web_mtb}. Please copy the folder manually." + ) + except Exception: # OSError log.warn( f"Failed to create symlink to {web_mtb}. Please copy the folder manually."