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

View File

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