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
-9
View File
@@ -7,7 +7,6 @@ from app.core.config import settings
from app.helper.directory import DirectoryHelper from app.helper.directory import DirectoryHelper
from app.log import logger from app.log import logger
from app.schemas import MediaType from app.schemas import MediaType
from helper.storage import StorageHelper
class StorageChain(ChainBase): class StorageChain(ChainBase):
@@ -18,7 +17,6 @@ class StorageChain(ChainBase):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.directoryhelper = DirectoryHelper() self.directoryhelper = DirectoryHelper()
self.storagehelper = StorageHelper()
def save_config(self, storage: str, conf: dict) -> None: def save_config(self, storage: str, conf: dict) -> None:
""" """
@@ -183,10 +181,3 @@ class StorageChain(ChainBase):
return self.delete_file(dir_item) return self.delete_file(dir_item)
return True return True
def get_storage(self, storage: str) -> Optional[schemas.StorageConf]:
"""
获取存储对象
"""
return self.storagehelper.get_storage(storage=storage)
+4 -6
View File
@@ -17,6 +17,7 @@ from app.core.config import settings, global_vars
from app.core.context import MediaInfo from app.core.context import MediaInfo
from app.core.meta import MetaBase from app.core.meta import MetaBase
from app.core.metainfo import MetaInfoPath from app.core.metainfo import MetaInfoPath
from app.core.event import eventmanager
from app.db.downloadhistory_oper import DownloadHistoryOper from app.db.downloadhistory_oper import DownloadHistoryOper
from app.db.models.downloadhistory import DownloadHistory from app.db.models.downloadhistory import DownloadHistory
from app.db.models.transferhistory import TransferHistory from app.db.models.transferhistory import TransferHistory
@@ -30,10 +31,9 @@ from app.schemas import TransferInfo, TransferTorrent, Notification, EpisodeForm
TransferTask, TransferQueue, TransferJob, TransferJobTask TransferTask, TransferQueue, TransferJob, TransferJobTask
from app.schemas.types import TorrentStatus, EventType, MediaType, ProgressKey, NotificationType, MessageChannel, \ from app.schemas.types import TorrentStatus, EventType, MediaType, ProgressKey, NotificationType, MessageChannel, \
SystemConfigKey, ChainEventType SystemConfigKey, ChainEventType
from app.schemas import StorageOperSelectionEventData
from app.utils.singleton import Singleton from app.utils.singleton import Singleton
from app.utils.string import StringUtils from app.utils.string import StringUtils
from core.event import eventmanager
from schemas import StorageOperSelectionEventData
downloader_lock = threading.Lock() downloader_lock = threading.Lock()
job_lock = threading.Lock() job_lock = threading.Lock()
@@ -707,9 +707,8 @@ class TransferChain(ChainBase, metaclass=Singleton):
# 广播事件,请示额外的源存储支持 # 广播事件,请示额外的源存储支持
source_oper = None source_oper = None
source_storage = self.storagechain.get_storage(task.fileitem.storage)
source_event_data = StorageOperSelectionEventData( source_event_data = StorageOperSelectionEventData(
storage_name=source_storage.name, storage=task.fileitem.storage,
) )
source_event = eventmanager.send_event(ChainEventType.StorageOperSelection, source_event_data) source_event = eventmanager.send_event(ChainEventType.StorageOperSelection, source_event_data)
# 使用事件返回的上下文数据 # 使用事件返回的上下文数据
@@ -720,9 +719,8 @@ class TransferChain(ChainBase, metaclass=Singleton):
# 广播事件,请示额外的目标存储支持 # 广播事件,请示额外的目标存储支持
target_oper = None target_oper = None
target_storage = self.storagechain.get_storage(task.target_storage)
target_event_data = StorageOperSelectionEventData( target_event_data = StorageOperSelectionEventData(
storage_name=target_storage.name, storage=task.target_storage,
) )
target_event = eventmanager.send_event(ChainEventType.StorageOperSelection, target_event_data) target_event = eventmanager.send_event(ChainEventType.StorageOperSelection, target_event_data)
# 使用事件返回的上下文数据 # 使用事件返回的上下文数据
+2 -2
View File
@@ -315,13 +315,13 @@ class StorageOperSelectionEventData(ChainEventData):
Attributes: Attributes:
# 输入参数 # 输入参数
storage_name (str): 存储名称 storage (str): 存储类型
# 输出参数 # 输出参数
storage_oper (Callable): 存储操作对象 storage_oper (Callable): 存储操作对象
""" """
# 输入参数 # 输入参数
storage_name: str = Field(..., description="存储名称") storage: str = Field(..., description="存储类型")
# 输出参数 # 输出参数
storage_oper: Optional[Callable] = Field(default=None, description="存储操作对象") storage_oper: Optional[Callable] = Field(default=None, description="存储操作对象")