From 62f0f5291d664a96114992502e6f1c0fcf462590 Mon Sep 17 00:00:00 2001 From: cxykevin Date: Fri, 3 May 2024 09:42:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=B2=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/downloader.py | 13 ++++++++++--- ui/installer.py | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/downloader.py b/lib/downloader.py index 653607b..399a137 100644 --- a/lib/downloader.py +++ b/lib/downloader.py @@ -1,3 +1,4 @@ +from re import T import time import os import shutil @@ -10,14 +11,19 @@ CHUNKSIZE = 1024 class Download_Theard(Thread): - def __init__(self, url, to, progress_callback, onfinish): + def __init__(self, url, to, progress_callback, onfinish, fname): self.url = url self.to = to self.progress_callback = progress_callback + self.fname = fname self.onfinish = onfinish Thread.__init__(self, daemon=True) def run(self): + finished = False + if (os.path.exists("software"+os.sep+self.fname)): + self.onfinish() + finished = True while 1: try: info("[downloader]download "+self.url) @@ -37,7 +43,8 @@ class Download_Theard(Thread): with py7zr.SevenZipFile(self.to, mode='r') as z: z.extractall(path="software") self.progress_callback(1) - self.onfinish() + if (finished == False): + self.onfinish() return except: pass @@ -60,5 +67,5 @@ def download_files(files, onfisish, anim_list): for i in files: threads.append(Download_Theard( - i["from"], i["to"], i["progbar"], progfinish)) + i["from"], i["to"], i["progbar"], progfinish, i["name"])) threads[-1].start() diff --git a/ui/installer.py b/ui/installer.py index ff378dd..aaa116c 100644 --- a/ui/installer.py +++ b/ui/installer.py @@ -84,7 +84,8 @@ def change_page_download(): download_l.append({ "from": i["source"], "to": "software"+os.sep+"cache"+os.sep+i["name"]+".7z", - "progbar": funclst[-1] + "progbar": funclst[-1], + "name": i["name"] }) runf()