update_manager: attempt client archive download before removing old client files

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-03 16:55:38 -05:00
parent d9edcd9396
commit 1f9d896e17
1 changed files with 2 additions and 2 deletions

View File

@ -937,6 +937,8 @@ class WebUpdater:
if self.version == self.remote_version: if self.version == self.remote_version:
# Already up to date # Already up to date
return return
self.notify_update_response(f"Downloading Client: {self.name}")
archive = await self.umgr.http_download_request(self.dl_url)
with tempfile.TemporaryDirectory( with tempfile.TemporaryDirectory(
suffix=self.name, prefix="client") as tempdir: suffix=self.name, prefix="client") as tempdir:
if os.path.isdir(self.path): if os.path.isdir(self.path):
@ -949,8 +951,6 @@ class WebUpdater:
shutil.move(src_path, dest_dir) shutil.move(src_path, dest_dir)
shutil.rmtree(self.path) shutil.rmtree(self.path)
os.mkdir(self.path) os.mkdir(self.path)
self.notify_update_response(f"Downloading Client: {self.name}")
archive = await self.umgr.http_download_request(self.dl_url)
with zipfile.ZipFile(io.BytesIO(archive)) as zf: with zipfile.ZipFile(io.BytesIO(archive)) as zf:
zf.extractall(self.path) zf.extractall(self.path)
# Move temporary files back into # Move temporary files back into