diff --git a/wine/installwine b/wine/installwine index 1b4eb744dc201ca70b43dea76ab80305628201dc..d0fb32efb103703a07697457163e5ef1bf1b76e1 100755 --- a/wine/installwine +++ b/wine/installwine @@ -230,7 +230,11 @@ class DownloadThread(QtCore.QThread): # 文件下载 timeout = 0 f = requests.get(self.fileUrl, stream=True) - allSize = int(f.headers["content-length"]) # 文件总大小 + if "content-length" in f.headers: + progressable = True # 大小已知,可使用进度条 + allSize = int(f.headers["content-length"]) # 文件总大小 + else: + progressable = False bytesRead = 0 with open(savePath, "wb") as filePart: for chunk in f.iter_content(chunk_size=1024): @@ -238,7 +242,8 @@ class DownloadThread(QtCore.QThread): #progressbar.update(int(part / show)) filePart.write(chunk) bytesRead += 1024 - self.ChangeDialog.emit(self.dialog, int(bytesRead / allSize * 100), int(bytesRead / 1024 / 1024), int(allSize / 1024 / 1024)) + if progressable: + self.ChangeDialog.emit(self.dialog, int(bytesRead / allSize * 100), int(bytesRead / 1024 / 1024), int(allSize / 1024 / 1024)) # 写入配置文件 rfile = open(f"{programPath}/winelist.json", "r") list = json.loads(rfile.read()) @@ -413,4 +418,4 @@ if __name__ == "__main__": # 图标 ui.centralWidget.setWindowIcon(QtGui.QIcon(f"{programPath}/../deepin-wine-runner.svg")) - app.exec_() \ No newline at end of file + app.exec_()