Skip to content

The only downloader you need. 下载器的集大成者。

refactor(core): 重构调用 新建任务 的逻辑,大幅增加项目可维护性;download_task 现在可以预获取 fileSize, 从而解决部分网站 HEAD 请求被拦截的问题;当记录文件无法读取时会自动删除,避免程序闪退

XiaoYouChR698c514ae73a
diff --git a/app/common/config.py b/app/common/config.py
index a9e87c5e..c8c555df 100644
--- a/app/common/config.py
+++ b/app/common/config.py
@@ -2,7 +2,7 @@
import sys
from re import compile
-from PySide6.QtCore import QDir, QRect, QTimer
+from PySide6.QtCore import QDir, QRect
from qfluentwidgets import (QConfig, ConfigItem, OptionsConfigItem, BoolValidator,
OptionsValidator, RangeConfigItem, RangeValidator,
FolderValidator, ConfigValidator, ConfigSerializer)
@@ -52,7 +52,7 @@ class Config(QConfig):
downloadFolder = ConfigItem(
"Download", "DownloadFolder", QDir.currentPath(), FolderValidator())
- maxBlockNum = RangeConfigItem("Download", "MaxBlockNum", 8, RangeValidator(1, 256))
+ preBlockNum = RangeConfigItem("Download", "PreBlockNum", 8, RangeValidator(1, 256))
maxTaskNum = RangeConfigItem("Download", "MaxTaskNum", 3, RangeValidator(1, 10))
speedLimitation = RangeConfigItem("Download", "SpeedLimitation", 0, RangeValidator(0, 104857600)) # 单位 KB
autoSpeedUp = ConfigItem("Download", "AutoSpeedUp", True, BoolValidator())
diff --git a/app/common/download_task.py b/app/common/download_task.py
index 41fb19a7..e134bf03 100644
--- a/app/common/download_task.py
+++ b/app/common/download_task.py
@@ -5,7 +5,6 @@ import time
from asyncio import Task
from pathlib import Path
from threading import Thread
-from time import sleep
import aiofiles
import httpx
@@ -37,7 +36,7 @@ class DownloadTask(QThread):
taskFinished = Signal() # 内置信号的不好用
gotWrong = Signal(str) # 😭 我出问题了
- def __init__(self, url, headers, preTaskNum: int = 8, filePath=None, fileName=None, autoSpeedUp=cfg.autoSpeedUp.value, parent=None):
+ def __init__(self, url, headers, preTaskNum: int = 8, filePath:str=None, fileName:str=None, autoSpeedUp:bool=False, fileSize:int=-1, parent=None):
super().__init__(parent)
self.aioLock = asyncio.Lock()
@@ -48,6 +47,7 @@ class DownloadTask(QThread):
self.filePath = filePath
self.preBlockNum = preTaskNum
self.autoSpeedUp = autoSpeedUp
+ self.fileSize = fileSize
self.ableToParallelDownload:bool
self.workers: list[DownloadWorker] = []
@@ -120,41 +120,47 @@ class DownloadTask(QThread):
def __initTask(self):
"""获取链接信息并初始化线程"""
- try:
- self.url, self.fileName, self.fileSize = getLinkInfo(self.url, self.headers, self.fileName)
-
+ if self.fileSize == -1 or not self.fileName:
+ try:
+ self.url, self.fileName, self.fileSize = getLinkInfo(self.url, self.headers, self.fileName)
+
+ if self.fileSize:
+ self.ableToParallelDownload = True
+ else:
+ self.ableToParallelDownload = False # 处理无法并行下载的情况
+
+ # 获取文件路径
+ if not self.filePath and Path(self.filePath).is_dir() == False:
+ self.filePath = Path.cwd()
+
+ else:
+ self.filePath = Path(self.filePath)
+ if not self.filePath.exists():
+ self.filePath.mkdir()
+
+ # 检验文件合法性并自动重命名
+ if sys.platform == "win32":
+ self.fileName = ''.join([i for i in self.fileName if i not in r'\/:*?"<>|']) # 去除Windows系统不允许的字符
+ if len(self.fileName) > 255:
+ self.fileName = self.fileName[:255]
+
+ Path(f"{self.filePath}/{self.fileName}").touch()
+
+ # 任务初始化完成
+ if self.ableToParallelDownload:
+ self.taskInited.emit(True)
+ else:
+ self.taskInited.emit(False)
+ self.preBlockNum = 1
+
+ except Exception as e: # 重试也没用
+ self.gotWrong.emit(repr(e))
+ else:
if self.fileSize:
self.ableToParallelDownload = True
else:
self.ableToParallelDownload = False # 处理无法并行下载的情况
- # 获取文件路径
- if not self.filePath and Path(self.filePath).is_dir() == False:
- self.filePath = Path.cwd()
-
- else:
- self.filePath = Path(self.filePath)
- if not self.filePath.exists():
- self.filePath.mkdir()
-
- # 检验文件合法性并自动重命名
- if sys.platform == "win32":
- self.fileName = ''.join([i for i in self.fileName if i not in r'\/:*?"<>|']) # 去除Windows系统不允许的字符
- if len(self.fileName) > 255:
- self.fileName = self.fileName[:255]
-
- Path(f"{self.filePath}/{self.fileName}").touch()
-
- # 任务初始化完成
- if self.ableToParallelDownload:
- self.taskInited.emit(True)
- else:
- self.taskInited.emit(False)
- self.preBlockNum = 1
-
- except Exception as e: # 重试也没用
- self.gotWrong.emit(str(e))
-
def __loadWorkers(self):
if not self.ableToParallelDownload:
# 如果无法并行下载,创建一个单线程的 worker
diff --git a/app/common/signal_bus.py b/app/common/signal_bus.py
index 538dbe64..14c71fd6 100644
--- a/app/common/signal_bus.py
+++ b/app/common/signal_bus.py
@@ -1,10 +1,26 @@
# coding: utf-8
from PySide6.QtCore import QObject, Signal
+from app.common.config import cfg, Headers
+
class SignalBus(QObject):
""" Signal bus """
- addTaskSignal = Signal(str, str, int, str, str, dict, bool) # url, filePath, maxBlockNum, name, status , headers, autoStart
+ addTaskSignal = Signal(str, str, str, dict, str, int, bool, str) # url, fileName, filePath, headers, status, preBlockNum, notCreateHistoryFile, fileSize
allTaskFinished = Signal()
signalBus = SignalBus()
+
+def addDownloadTask(url: str, fileName: str = None, filePath: str = None,
+ headers: dict = None, status:str = "working", preBlockNum: int= None, notCreateHistoryFile: bool = False, fileSize: str = "-1"):
+ """ Global function to add download task """
+ if not filePath:
+ filePath = cfg.downloadFolder.value
+
+ if not preBlockNum:
+ preBlockNum = cfg.preBlockNum.value
+
+ if not headers:
+ headers = Headers
+
+ signalBus.addTaskSignal.emit(url, fileName, filePath, headers, status, preBlockNum, notCreateHistoryFile, fileSize)
\ No newline at end of file
diff --git a/app/components/add_task_dialog.py b/app/components/add_task_dialog.py
index d871763c..26865d78 100644
--- a/app/components/add_task_dialog.py
+++ b/app/components/add_task_dialog.py
@@ -14,7 +14,7 @@ from .Ui_AddTaskOptionDialog import Ui_AddTaskOptionDialog
from .custom_dialogs import EditHeadersDialog
from ..common.config import cfg, Headers
from ..common.methods import getReadableSize, getLinkInfo
-from ..common.signal_bus import signalBus
+from ..common.signal_bus import addDownloadTask
urlRe = re.compile(r"^" +
"(https?://)" +
@@ -66,7 +66,7 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
)
self.blockNumCard = RangeSettingCard(
- cfg.maxBlockNum,
+ cfg.preBlockNum,
FIF.CLOUD,
"下载线程数",
'',
@@ -133,9 +133,7 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
for i in range(self.taskTableWidget.rowCount()):
item = self.taskTableWidget.item(i, 0)
- signalBus.addTaskSignal.emit(item.data(1),
- str(path), self.blockNumCard.configItem.value,
- item.text(), "working", self.customHeaders, False) # 使用新的 customHeaders
+ addDownloadTask(item.data(1), item.text(), str(path), self.customHeaders, preBlockNum=self.blockNumCard.configItem.value)
self.close()
@@ -155,9 +153,7 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
for i in range(self.taskTableWidget.rowCount()):
item = self.taskTableWidget.item(i, 0)
- signalBus.addTaskSignal.emit(item.data(1),
- str(path), self.blockNumCard.configItem.value,
- item.text(), "paused", self.customHeaders, False) # 使用新的 customHeaders
+ addDownloadTask(item.data(1), item.text(), str(path), self.customHeaders, "waiting", self.blockNumCard.configItem.value)
self.close()
diff --git a/app/components/task_card.py b/app/components/task_card.py
index aa0aaad9..0e173b8a 100644
--- a/app/components/task_card.py
+++ b/app/components/task_card.py
@@ -17,11 +17,12 @@ from ..common.download_task import DownloadTask
from ..common.methods import getReadableSize, openFile
from ..view.pop_up_window import PopUpWindow
+
class TaskCard(CardWidget, Ui_TaskCard):
taskStatusChanged = Signal()
- def __init__(self, url, path, maxBlockNum: int, headers: dict, name: str = None, status: str = "working",
- parent=None, autoCreated=False):
+ def __init__(self, url:str, fileName: str, filePath:str, preBlockNum: int, headers: dict, status: str,
+ notCreatedHistoryFile:bool, fileSize: int=-1, parent=None):
super().__init__(parent=parent)
self.setupUi(self)
@@ -29,11 +30,12 @@ class TaskCard(CardWidget, Ui_TaskCard):
# 初始化参数
self.url = url
self.headers = headers
- self.fileName = name
- self.filePath = path
- self.maxBlockNum = maxBlockNum
+ self.fileName = fileName
+ self.filePath = filePath
+ self.preBlockNum = preBlockNum
self.status = status # working waiting paused finished
- self.autoCreated = autoCreated # 事实上用来记录历史文件是否已经创建
+ self.notCreateHistoryFile = notCreatedHistoryFile # 事实上用来记录历史文件是否已经创建
+ self.fileSize = fileSize
self.ableToParallelDownload = False # 是否可以并行下载
self.__clickPos = None
@@ -52,8 +54,8 @@ class TaskCard(CardWidget, Ui_TaskCard):
if not self.status == "finished": # 不是已完成的任务才要进行的操作
self.pauseButton.setDisabled(True)
- if name:
- self.task = DownloadTask(url, headers, maxBlockNum, path, name)
+ if fileName:
+ self.__instantiateTask(url, filePath, preBlockNum, headers, fileSize, fileName)
self.__onTaskInited(self.ableToParallelDownload)
@@ -63,7 +65,7 @@ class TaskCard(CardWidget, Ui_TaskCard):
self.__showInfo("排队中...")
else:
- self.task = DownloadTask(url, headers, maxBlockNum, path)
+ self.__instantiateTask(url, filePath, preBlockNum, headers, fileSize)
self.__connectSignalToSlot()
@@ -85,7 +87,7 @@ class TaskCard(CardWidget, Ui_TaskCard):
# 连接信号到槽
self.pauseButton.clicked.connect(self.pauseTask)
self.cancelButton.clicked.connect(self.cancelTask)
- self.folderButton.clicked.connect(lambda: openFile(path))
+ self.folderButton.clicked.connect(lambda: openFile(filePath))
if self.status == "working":
# 开始下载
@@ -93,6 +95,10 @@ class TaskCard(CardWidget, Ui_TaskCard):
elif self.status == "paused" or self.status == "waiting":
self.pauseButton.setIcon(FIF.PLAY)
+ def __instantiateTask(self, url:str, filePath: str, preBlockNum: int, headers: dict, fileSize: int=-1, fileName: str=None):
+ autoSpeedUp = cfg.autoSpeedUp.value
+ self.task = DownloadTask(url, headers, preBlockNum, filePath, fileName, autoSpeedUp, fileSize)
+
def updateTaskRecord(self, newStatus: str):
recordPath = "{}/Ghost Downloader 记录文件".format(cfg.appPath)
@@ -116,7 +122,7 @@ class TaskCard(CardWidget, Ui_TaskCard):
if (record["url"] == self.url and
record["fileName"] == self.fileName and
record["filePath"] == str(self.filePath) and
- record["blockNum"] == self.maxBlockNum and
+ record["blockNum"] == self.preBlockNum and
record["headers"] == self.headers):
found = True
if newStatus != "deleted":
@@ -131,9 +137,10 @@ class TaskCard(CardWidget, Ui_TaskCard):
"url": self.url,
"fileName": self.fileName,
"filePath": str(self.filePath),
- "blockNum": self.maxBlockNum,
+ "blockNum": self.preBlockNum,
"status": self.status,
- "headers": self.headers
+ "headers": self.headers,
+ "fileSize": self.fileSize
})
# 写回记录文件
@@ -152,6 +159,7 @@ class TaskCard(CardWidget, Ui_TaskCard):
def __onTaskInited(self, ableToParallelDownload: bool):
self.fileName = self.task.fileName
+ self.fileSize = self.task.fileSize
self.ableToParallelDownload = ableToParallelDownload
# TODO 因为Windows会返回已经处理过的只有左上角一点点的图像,所以需要超分辨率触发条件
@@ -174,15 +182,15 @@ class TaskCard(CardWidget, Ui_TaskCard):
if self.ableToParallelDownload:
self.progressBar.deleteLater()
- self.progressBar = TaskProgressBar(self.maxBlockNum, self)
+ self.progressBar = TaskProgressBar(self.preBlockNum, self)
self.progressBar.setObjectName(u"progressBar")
self.verticalLayout.addWidget(self.progressBar)
# 写入未完成任务记录文件,以供下次打开时继续下载
- if self.fileName and not self.autoCreated:
+ if self.fileName and not self.notCreateHistoryFile:
self.updateTaskRecord(self.status)
- self.autoCreated = True
+ self.notCreateHistoryFile = True
self.pauseButton.setEnabled(True)
else:
@@ -220,9 +228,9 @@ class TaskCard(CardWidget, Ui_TaskCard):
self.pauseButton.setIcon(FIF.PAUSE)
try:
- self.task = DownloadTask(self.url, self.headers, self.maxBlockNum, self.filePath, self.fileName)
+ self.__instantiateTask(self.url, self.filePath, self.preBlockNum, self.headers, self.fileSize, self.fileName)
except: # TODO 没有 fileName 的情况
- self.task = DownloadTask(self.url, self.headers, self.maxBlockNum, self.filePath)
+ self.__instantiateTask(self.url, self.filePath, self.preBlockNum, self.headers, self.fileSize)
self.__connectSignalToSlot()
diff --git a/app/components/update_dialog.py b/app/components/update_dialog.py
index 87f8d3d7..f2141975 100644
--- a/app/components/update_dialog.py
+++ b/app/components/update_dialog.py
@@ -5,9 +5,9 @@ from PySide6.QtWidgets import QTableWidgetItem
from loguru import logger
from qfluentwidgets import InfoBar, InfoBarPosition, FluentStyleSheet
-from app.common.config import VERSION, cfg, Headers
+from app.common.config import VERSION
from app.common.methods import getProxy, getLocalTimeFromGithubApiTime, getReadableSize
-from app.common.signal_bus import signalBus
+from app.common.signal_bus import addDownloadTask
from app.components.Ui_UpdateDialog import Ui_UpdateDialog
from app.components.custom_mask_dialog_base import MaskDialogBase
@@ -89,7 +89,7 @@ class UpdateDialog(MaskDialogBase, Ui_UpdateDialog):
def __onYesButtonClicked(self):
url = self.urls[self.tableView.currentRow()]
- signalBus.addTaskSignal.emit(url, cfg.downloadFolder.value, cfg.maxBlockNum.value, None, "working", Headers ,False)
+ addDownloadTask(url)
self.close()
def __showResponse(parent, content: dict):
diff --git a/app/view/main_window.py b/app/view/main_window.py
index 968a9d58..3e0f0bf4 100644
--- a/app/view/main_window.py
+++ b/app/view/main_window.py
@@ -18,7 +18,7 @@ from .task_interface import TaskInterface
from ..common.config import cfg, Headers, attachmentTypes
from ..common.custom_socket import GhostDownloaderSocketServer
from ..common.methods import getLinkInfo, bringWindowToTop
-from ..common.signal_bus import signalBus
+from ..common.signal_bus import addDownloadTask
from ..components.add_task_dialog import AddTaskOptionDialog
from ..components.custom_tray import CustomSystemTrayIcon
from ..components.update_dialog import checkUpdate
@@ -76,16 +76,19 @@ class MainWindow(MSFluentWindow):
# 创建未完成的任务
historyFile = Path("{}/Ghost Downloader 记录文件".format(cfg.appPath))
if historyFile.exists():
- with open(historyFile, 'rb') as f:
- try:
- while True:
- taskRecord = pickle.load(f)
- logger.debug(f"Unfinished Task is following: {taskRecord}")
- signalBus.addTaskSignal.emit(taskRecord['url'], taskRecord['filePath'], taskRecord['blockNum'],
- taskRecord['fileName'], taskRecord['status'],
- taskRecord['headers'], True)
- except EOFError:
- pass
+ f = open(historyFile, 'rb')
+ try:
+ while True:
+ taskRecord = pickle.load(f)
+ logger.debug(f"Unfinished Task is following: {taskRecord}")
+ addDownloadTask(taskRecord['url'], taskRecord['fileName'], taskRecord['filePath'], taskRecord['status'], taskRecord['blockNum'], taskRecord['headers'], True, taskRecord['fileSize'])
+ except EOFError: # 读取完毕
+ f.close()
+ except Exception as e:
+ logger.error(f"Failed to load unfinished task: {e}")
+ f.close()
+ historyFile.unlink()
+ historyFile.touch()
else:
historyFile.touch()
@@ -135,8 +138,8 @@ class MainWindow(MSFluentWindow):
self.browserExtensionServer = None
def __addDownloadTaskFromWebSocket(self, url: str, headers: dict):
- signalBus.addTaskSignal.emit(url, cfg.downloadFolder.value, cfg.maxBlockNum.value, None, "working", headers,
- None)
+ # signalBus.addTaskSignal.emit(url, cfg.downloadFolder.value, cfg.preBlockNum.value, None, "working", headers,
+ # None)
self.tray.showMessage(self.windowTitle(), f"已捕获来自浏览器的下载任务: \n{url}", self.windowIcon())
def toggleTheme(self, callback: str):
diff --git a/app/view/pop_up_window.py b/app/view/pop_up_window.py
index 7edf6339..117616f7 100644
--- a/app/view/pop_up_window.py
+++ b/app/view/pop_up_window.py
@@ -1,4 +1,3 @@
-import weakref
from os.path import dirname, basename
from PySide6.QtCore import Qt, QUrl, QTimer, QEasingCurve, QPropertyAnimation, QRect, QFileInfo, QObject
diff --git a/app/view/setting_interface.py b/app/view/setting_interface.py
index 4b0daa60..6e8f9507 100644
--- a/app/view/setting_interface.py
+++ b/app/view/setting_interface.py
@@ -8,8 +8,7 @@ from PySide6.QtGui import QDesktopServices
from PySide6.QtWidgets import QWidget, QFileDialog, QVBoxLayout, QApplication, QButtonGroup, QHBoxLayout, QSpacerItem, \
QSizePolicy
from qfluentwidgets import FluentIcon as FIF, InfoBarPosition, ExpandGroupSettingCard, ConfigItem, \
- BodyLabel, RadioButton, ComboBox, LineEdit, ComboBoxSettingCard, FlyoutView, Flyout, SettingCard, CompactSpinBox, \
- SpinBox
+ BodyLabel, RadioButton, ComboBox, LineEdit, ComboBoxSettingCard, FlyoutView, Flyout, SettingCard, CompactSpinBox
from qfluentwidgets import InfoBar
from qfluentwidgets import (SettingCardGroup, SwitchSettingCard, PushSettingCard,
HyperlinkCard, PrimaryPushSettingCard, SmoothScrollArea,
@@ -208,9 +207,9 @@ class SettingInterface(SmoothScrollArea):
"下载相关设置", self.scrollWidget)
self.blockNumCard = RangeSettingCard(
- cfg.maxBlockNum,
+ cfg.preBlockNum,
FIF.CLOUD,
- "下载线程数",
+ "预分配线程数",
'线程越多,下载越快。线程数大于 64 时,有触发反爬导致文件损坏的风险',
self.downloadGroup
)
@@ -239,7 +238,7 @@ class SettingInterface(SmoothScrollArea):
self.autoSpeedUpCard = SwitchSettingCard(
FIF.SPEED_HIGH,
"自动提速",
- "AI 实时检测线程效率并自动重新分配线程以提高下载速度",
+ "AI 实时检测各线程效率并自动增加线程数以提高下载速度",
cfg.autoSpeedUp,
self.downloadGroup
)
@@ -579,7 +578,7 @@ class SettingInterface(SmoothScrollArea):
cfg.themeChanged.connect(setTheme)
# download
- self.blockNumCard.valueChanged.connect(lambda: cfg.set(cfg.maxBlockNum, self.blockNumCard.configItem.value))
+ self.blockNumCard.valueChanged.connect(lambda: cfg.set(cfg.preBlockNum, self.blockNumCard.configItem.value))
self.downloadFolderCard.clicked.connect(
self.__onDownloadFolderCardClicked)
diff --git a/app/view/task_interface.py b/app/view/task_interface.py
index 45a79abd..63f6fd66 100644
--- a/app/view/task_interface.py
+++ b/app/view/task_interface.py
@@ -1,10 +1,10 @@
-from PySide6.QtCore import Qt, Signal, Slot
+from PySide6.QtCore import Qt, Slot
from PySide6.QtWidgets import QWidget, QFrame, QHBoxLayout, QVBoxLayout, QSpacerItem, QSizePolicy
from loguru import logger
-from qfluentwidgets import FluentIcon as FIF, SmoothScrollArea, TitleLabel, PrimaryPushButton, PushButton, InfoBar, \
+from qfluentwidgets import FluentIcon as FIF, SmoothScrollArea, PrimaryPushButton, PushButton, InfoBar, \
InfoBarPosition, ToggleButton
-from ..common.config import cfg, Headers
+from ..common.config import cfg
from ..common.signal_bus import signalBus
from ..components.custom_dialogs import DelDialog, PlanTaskDialog
from ..components.task_card import TaskCard
@@ -30,8 +30,8 @@ class TaskInterface(SmoothScrollArea):
self.setWidget(self.scrollWidget)
self.setWidgetResizable(True)
- # 在这里创建下载任务
- signalBus.addTaskSignal.connect(self.addDownloadTask)
+ # 连接新建下载任务信号
+ signalBus.addTaskSignal.connect(self.__addDownloadTask)
# Apply QSS
self.setStyleSheet("""QScrollArea, .QWidget {
@@ -92,16 +92,10 @@ class TaskInterface(SmoothScrollArea):
self.scrollWidget.setMinimumWidth(816)
- def addDownloadTask(self, url: str, path: str, block_num: int, name: str = None, status:str = "working",
- headers: dict = Headers, autoCreated: bool = False):
- # # 任务唯一标识符
- # number = len(self.cards)
- # _ = TaskCard(url, path, block_num, number, pixmap, name, self.scrollWidget, autoCreated)
- # _.removeTaskSignal.connect(self.removeTask)
-
+ def __addDownloadTask(self, url: str, fileName: str, filePath: str,
+ headers: dict, status:str, preBlockNum: int, notCreateHistoryFile: bool, fileSize: str="-1"):
# 逐个对照现有任务url, 若重复则不添加
for card in self.cards:
-
if card.url == url:
InfoBar.error(
title='错误',
@@ -114,8 +108,9 @@ class TaskInterface(SmoothScrollArea):
parent=self.parent()
)
return
+
try:
- if card.fileName == name and card.filePath == path:
+ if card.fileName == fileName and card.filePath == filePath:
InfoBar.error(
title='错误',
content="已创建相同文件名和路径的任务!",
@@ -135,7 +130,7 @@ class TaskInterface(SmoothScrollArea):
if len(runningTasks) >= cfg.maxTaskNum.value and status == "working":
status = "waiting"
- _ = TaskCard(url, path, block_num, headers, name, status, self.scrollWidget, autoCreated)
+ _ = TaskCard(url, fileName, filePath, preBlockNum, headers, status, notCreateHistoryFile, int(fileSize), self.scrollWidget)
_.taskStatusChanged.connect(self.__handleTaskStatusChange)
diff --git a/plugins/jy_os_page.py b/plugins/jy_os_page.py
index a8d84bae..b0ace623 100644
--- a/plugins/jy_os_page.py
+++ b/plugins/jy_os_page.py
@@ -17,7 +17,7 @@ from qfluentwidgets.components.dialog_box.mask_dialog_base import MaskDialogBase
from app.common.config import Headers
from app.common.methods import getProxy
from app.common.plugin_base import PluginBase
-from app.common.signal_bus import signalBus
+from app.common.signal_bus import signalBus, addDownloadTask
class JyOSPagePlugin(PluginBase):
@@ -246,9 +246,8 @@ class DownloadOptionDialog(MaskDialogBase):
if not os.access(path, os.W_OK):
MessageBox("错误", "似乎是没有权限向此目录写入文件", self)
- signalBus.addTaskSignal.emit(self.list[self.versionCard.comboBox.currentIndex()]["Url"],
- str(path), self.blockNumCard.configItem.value,
- "", "working", Headers, False)
+ addDownloadTask(self.list[self.versionCard.comboBox.currentIndex()]["Url"],
+ filePath=str(path), preBlockNum=self.blockNumCard.configItem.value)
self.close()
def __onDownloadFolderCardClicked(self):