Copy wakatime-cli when symlink fails

This commit is contained in:
Alan Hamlett 2022-01-06 18:16:02 -08:00
parent 66f5f48f33
commit 7d2bd0b7c5
1 changed files with 15 additions and 13 deletions

View File

@ -908,22 +908,24 @@ def download(url, filePath):
raise
def is_symlink(path):
try:
return os.is_symlink(path)
except:
return False
def createSymlink():
link = os.path.join(RESOURCES_FOLDER, 'wakatime-cli')
if is_win:
link = os.path.join(RESOURCES_FOLDER, 'wakatime-cli.exe')
if os.path.exists(link):
try:
os.remove(link)
except:
log(traceback.format_exc())
link = link + '.exe'
elif os.path.exists(link) and is_symlink(link):
return # don't re-create symlink on Unix-like platforms
try:
os.symlink(getCliLocation(), link)
except:
try:
shutil.copy2(getCliLocation(), link)
except:
log(traceback.format_exc())
else:
link = os.path.join(RESOURCES_FOLDER, 'wakatime-cli')
if not os.path.exists(link):
try:
os.symlink(getCliLocation(), link)
except:
pass