only remove wakatime-cli after finished downloading new one

This commit is contained in:
Alan Hamlett 2021-12-31 16:42:11 -08:00
parent bebb46dda6
commit e5331d3086
1 changed files with 6 additions and 6 deletions

View File

@ -626,18 +626,18 @@ class DownloadCLI(threading.Thread):
if not os.path.exists(RESOURCES_FOLDER):
os.makedirs(RESOURCES_FOLDER)
if isCliInstalled():
try:
os.remove(getCliLocation())
except:
log(DEBUG, traceback.format_exc())
try:
url = cliDownloadUrl()
log(DEBUG, 'Downloading wakatime-cli from {url}'.format(url=url))
zip_file = os.path.join(RESOURCES_FOLDER, 'wakatime-cli.zip')
download(url, zip_file)
if isCliInstalled():
try:
os.remove(getCliLocation())
except:
log(DEBUG, traceback.format_exc())
log(INFO, 'Extracting wakatime-cli...')
with ZipFile(zip_file) as zf:
zf.extractall(RESOURCES_FOLDER)