This commit is contained in:
jxxghp
2025-05-02 08:31:38 +08:00
parent 91d0f76783
commit 85b55aa924
3 changed files with 6 additions and 17 deletions

View File

@@ -7,7 +7,6 @@ from app.core.config import settings
from app.helper.directory import DirectoryHelper
from app.log import logger
from app.schemas import MediaType
from helper.storage import StorageHelper
class StorageChain(ChainBase):
@@ -18,7 +17,6 @@ class StorageChain(ChainBase):
def __init__(self):
super().__init__()
self.directoryhelper = DirectoryHelper()
self.storagehelper = StorageHelper()
def save_config(self, storage: str, conf: dict) -> None:
"""
@@ -183,10 +181,3 @@ class StorageChain(ChainBase):
return self.delete_file(dir_item)
return True
def get_storage(self, storage: str) -> Optional[schemas.StorageConf]:
"""
获取存储对象
"""
return self.storagehelper.get_storage(storage=storage)

View File

@@ -17,6 +17,7 @@ from app.core.config import settings, global_vars
from app.core.context import MediaInfo
from app.core.meta import MetaBase
from app.core.metainfo import MetaInfoPath
from app.core.event import eventmanager
from app.db.downloadhistory_oper import DownloadHistoryOper
from app.db.models.downloadhistory import DownloadHistory
from app.db.models.transferhistory import TransferHistory
@@ -30,10 +31,9 @@ from app.schemas import TransferInfo, TransferTorrent, Notification, EpisodeForm
TransferTask, TransferQueue, TransferJob, TransferJobTask
from app.schemas.types import TorrentStatus, EventType, MediaType, ProgressKey, NotificationType, MessageChannel, \
SystemConfigKey, ChainEventType
from app.schemas import StorageOperSelectionEventData
from app.utils.singleton import Singleton
from app.utils.string import StringUtils
from core.event import eventmanager
from schemas import StorageOperSelectionEventData
downloader_lock = threading.Lock()
job_lock = threading.Lock()
@@ -707,9 +707,8 @@ class TransferChain(ChainBase, metaclass=Singleton):
# 广播事件,请示额外的源存储支持
source_oper = None
source_storage = self.storagechain.get_storage(task.fileitem.storage)
source_event_data = StorageOperSelectionEventData(
storage_name=source_storage.name,
storage=task.fileitem.storage,
)
source_event = eventmanager.send_event(ChainEventType.StorageOperSelection, source_event_data)
# 使用事件返回的上下文数据
@@ -720,9 +719,8 @@ class TransferChain(ChainBase, metaclass=Singleton):
# 广播事件,请示额外的目标存储支持
target_oper = None
target_storage = self.storagechain.get_storage(task.target_storage)
target_event_data = StorageOperSelectionEventData(
storage_name=target_storage.name,
storage=task.target_storage,
)
target_event = eventmanager.send_event(ChainEventType.StorageOperSelection, target_event_data)
# 使用事件返回的上下文数据

View File

@@ -315,13 +315,13 @@ class StorageOperSelectionEventData(ChainEventData):
Attributes:
# 输入参数
storage_name (str): 存储名称
storage (str): 存储类型
# 输出参数
storage_oper (Callable): 存储操作对象
"""
# 输入参数
storage_name: str = Field(..., description="存储名称")
storage: str = Field(..., description="存储类型")
# 输出参数
storage_oper: Optional[Callable] = Field(default=None, description="存储操作对象")