From 7e347a458daeffbfe33e0d41a0b0ebf9a984fb68 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 28 Feb 2025 21:23:44 +0800 Subject: [PATCH] add ScanFileAction --- app/actions/fetch_downloads.py | 3 +++ app/actions/transfer_file.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/app/actions/fetch_downloads.py b/app/actions/fetch_downloads.py index 605f91a4..a0c18bb7 100644 --- a/app/actions/fetch_downloads.py +++ b/app/actions/fetch_downloads.py @@ -59,6 +59,9 @@ class FetchDownloadsAction(BaseAction): if t.progress >= 100: logger.info(f"下载任务 {download.download_id} 已完成") download.completed = True + else: + logger.info(f"下载任务 {download.download_id} 未完成") + download.completed = False if all([d.completed for d in self._downloads]): self.job_done() return context diff --git a/app/actions/transfer_file.py b/app/actions/transfer_file.py index e45f6586..ce68b60b 100644 --- a/app/actions/transfer_file.py +++ b/app/actions/transfer_file.py @@ -6,6 +6,7 @@ from pydantic import Field from app.actions import BaseAction from app.core.config import global_vars +from app.db.transferhistory_oper import TransferHistoryOper from app.schemas import ActionParams, ActionContext from app.chain.storage import StorageChain from app.chain.transfer import TransferChain @@ -32,6 +33,7 @@ class TransferFileAction(BaseAction): super().__init__() self.transferchain = TransferChain() self.storagechain = StorageChain() + self.transferhis = TransferHistoryOper() @classmethod @property @@ -69,6 +71,10 @@ class TransferFileAction(BaseAction): if not fileitem: logger.info(f"文件 {download.path} 不存在") continue + transferd = self.transferhis.get_by_src(fileitem.path, storage=fileitem.storage) + if transferd: + # 已经整理过的文件不再整理 + continue logger.info(f"开始整理文件 {download.path} ...") state, errmsg = self.transferchain.do_transfer(fileitem, background=False) if not state: @@ -82,6 +88,10 @@ class TransferFileAction(BaseAction): for fileitem in copy.deepcopy(context.fileitems): if global_vars.is_workflow_stopped(workflow_id): 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) if not state: