This commit is contained in:
jxxghp
2025-01-08 11:37:58 +08:00
parent 6f593beeed
commit 9446e88012
2 changed files with 117 additions and 105 deletions
+22 -11
View File
@@ -504,14 +504,20 @@ class TransferChain(ChainBase, metaclass=Singleton):
if not task:
return
# 维护整理任务视图
with task_lock:
self.jobview.add_task(task)
self.__put_to_jobview(task)
# 添加到队列
self._queue.put(TransferQueue(
task=task,
callback=callback or self.__default_callback
))
def __put_to_jobview(self, task: TransferTask):
"""
添加到作业视图
"""
with task_lock:
self.jobview.add_task(task)
def remove_from_queue(self, fileitem: FileItem):
"""
从待整理队列移除
@@ -578,10 +584,6 @@ class TransferChain(ChainBase, metaclass=Singleton):
self.progress.update(value=processed_num / total_num * 100,
text=__process_msg,
key=ProgressKey.FileTransfer)
# 移除已完成的任务
with task_lock:
if self.jobview.is_done(task):
self.jobview.remove_job(task)
except queue.Empty:
if not __queue_start:
# 结束进度
@@ -608,6 +610,10 @@ class TransferChain(ChainBase, metaclass=Singleton):
"""
处理整理任务
"""
try:
# 维护整理任务视图
if task.background:
self.__put_to_jobview(task)
# 识别
if not task.mediainfo:
mediainfo = None
@@ -712,6 +718,12 @@ class TransferChain(ChainBase, metaclass=Singleton):
return transferinfo.success, transferinfo.message
finally:
# 移除已完成的任务
with task_lock:
if self.jobview.is_done(task):
self.jobview.remove_job(task)
def get_queue_tasks(self) -> List[TransferJob]:
"""
获取整理任务列表
@@ -792,7 +804,7 @@ class TransferChain(ChainBase, metaclass=Singleton):
# 非MoviePilot下载的任务,按文件识别
mediainfo = None
# 执行整理,匹配源目录
# 执行实时整理,匹配源目录
state, errmsg = self.do_transfer(
fileitem=FileItem(
storage="local",
@@ -1095,12 +1107,11 @@ class TransferChain(ChainBase, metaclass=Singleton):
downloader=downloader,
download_hash=download_hash,
download_history=download_history,
manual=manual
manual=manual,
background=background
)
if background:
self.put_to_queue(
task=transfer_task
)
self.put_to_queue(task=transfer_task)
logger.info(f"{file_path.name} 已添加到整理队列")
else:
state, err_msg = self.__handle_transfer(
+1
View File
@@ -64,6 +64,7 @@ class TransferTask(BaseModel):
download_hash: Optional[str] = None
download_history: Optional[DownloadHistory] = None
manual: Optional[bool] = False
background: Optional[bool] = True
def to_dict(self):
"""