add ScanFileAction

This commit is contained in:
jxxghp
2025-02-28 21:23:44 +08:00
parent cce71f23e2
commit 7e347a458d
2 changed files with 13 additions and 0 deletions

View File

@@ -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

View File

@@ -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: