- 任务工作流支持手动停止、支持导入导出流程数据、完善动作组件等
This commit is contained in:
jxxghp
2025-03-01 15:51:15 +08:00
parent a55632051b
commit ed8895dfbb
3 changed files with 20 additions and 5 deletions

View File

@@ -58,6 +58,15 @@ class TransferFileAction(BaseAction):
"""
从 downloads / fileitems 中整理文件记录到fileitems
"""
def check_continue():
"""
检查是否继续整理文件
"""
if global_vars.is_workflow_stopped(workflow_id):
return False
return True
params = TransferFileParams(**params)
if params.source == "downloads":
# 从下载任务中整理文件
@@ -86,14 +95,15 @@ class TransferFileAction(BaseAction):
else:
# 从 fileitems 中整理文件
for fileitem in copy.deepcopy(context.fileitems):
if global_vars.is_workflow_stopped(workflow_id):
if not check_continue():
break
transferd = self.transferhis.get_by_src(fileitem.path, storage=fileitem.storage)
if transferd:
# 已经整理过的文件不再整理
continue
logger.info(f"开始整理文件 {fileitem.path} ...")
state, errmsg = self.transferchain.do_transfer(fileitem, background=False)
state, errmsg = self.transferchain.do_transfer(fileitem, background=False,
continue_callback=check_continue)
if not state:
self._has_error = True
logger.error(f"整理文件 {fileitem.path} 失败: {errmsg}")

View File

@@ -905,7 +905,7 @@ class TransferChain(ChainBase, metaclass=Singleton):
season: int = None, epformat: EpisodeFormat = None, min_filesize: int = 0,
downloader: str = None, download_hash: str = None,
force: bool = False, background: bool = True,
manual: bool = False) -> Tuple[bool, str]:
manual: bool = False, continue_callback: Callable = None) -> Tuple[bool, str]:
"""
执行一个复杂目录的整理操作
:param fileitem: 文件项
@@ -926,6 +926,7 @@ class TransferChain(ChainBase, metaclass=Singleton):
:param force: 是否强制整理
:param background: 是否后台运行
:param manual: 是否手动整理
:param continue_callback: 继续处理回调
返回:成功标识,错误信息
"""
@@ -991,6 +992,8 @@ class TransferChain(ChainBase, metaclass=Singleton):
for file_item, bluray_dir in file_items:
if global_vars.is_system_stopped:
break
if continue_callback and not continue_callback():
break
file_path = Path(file_item.path)
# 回收站及隐藏的文件不处理
if file_item.path.find('/@Recycle/') != -1 \
@@ -1111,6 +1114,8 @@ class TransferChain(ChainBase, metaclass=Singleton):
for transfer_task in transfer_tasks:
if global_vars.is_system_stopped:
break
if continue_callback and not continue_callback():
break
# 更新进度
__process_msg = f"正在整理 {processed_num + fail_num + 1}/{total_num}{transfer_task.fileitem.name} ..."
logger.info(__process_msg)

View File

@@ -1,2 +1,2 @@
APP_VERSION = 'v2.3.1'
FRONTEND_VERSION = 'v2.3.1'
APP_VERSION = 'v2.3.2'
FRONTEND_VERSION = 'v2.3.2'