添加已下载检测

This commit is contained in:
cxykevin 2024-05-03 09:42:03 +08:00
parent 52d28f42d2
commit 62f0f5291d
2 changed files with 12 additions and 4 deletions

View File

@ -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()

View File

@ -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()