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

View File

@ -908,22 +908,24 @@ def download(url, filePath):
raise
def createSymlink():
if is_win:
link = os.path.join(RESOURCES_FOLDER, 'wakatime-cli.exe')
if os.path.exists(link):
def is_symlink(path):
try:
os.remove(link)
return os.is_symlink(path)
except:
return False
def createSymlink():
link = os.path.join(RESOURCES_FOLDER, 'wakatime-cli')
if is_win:
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:
log(traceback.format_exc())
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