From 11075a4012a38ab055795db5f4ced675b7cf289f Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 5 Jun 2025 13:33:39 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=A2=9E=E5=8A=A0=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E5=86=85=E5=AD=98=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/message.py | 2 ++ app/chain/search.py | 2 ++ app/chain/subscribe.py | 3 +++ app/chain/transfer.py | 2 ++ 4 files changed, 9 insertions(+) diff --git a/app/chain/message.py b/app/chain/message.py index 10276afc..2824f3e7 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -11,6 +11,7 @@ from app.core.config import settings from app.core.context import MediaInfo, Context from app.core.meta import MetaBase from app.db.user_oper import UserOper +from app.helper.memory import memory_optimized from app.helper.torrent import TorrentHelper from app.log import logger from app.schemas import Notification, NotExistMediaInfo, CommingMessage @@ -117,6 +118,7 @@ class MessageChain(ChainBase): # 处理消息 self.handle_message(channel=channel, source=source, userid=userid, username=username, text=text) + @memory_optimized(force_gc_after=True, log_memory=True) def handle_message(self, channel: MessageChannel, source: str, userid: Union[str, int], username: str, text: str) -> None: """ diff --git a/app/chain/search.py b/app/chain/search.py index 5f7f0a87..1b35dc63 100644 --- a/app/chain/search.py +++ b/app/chain/search.py @@ -12,6 +12,7 @@ from app.core.context import MediaInfo, TorrentInfo from app.core.event import eventmanager, Event from app.core.metainfo import MetaInfo from app.db.systemconfig_oper import SystemConfigOper +from app.helper.memory import memory_optimized from app.helper.progress import ProgressHelper from app.helper.sites import SitesHelper from app.helper.torrent import TorrentHelper @@ -97,6 +98,7 @@ class SearchChain(ChainBase): logger.error(f'加载搜索结果失败:{str(e)} - {traceback.format_exc()}') return [] + @memory_optimized(force_gc_after=True, log_memory=True) def process(self, mediainfo: MediaInfo, keyword: Optional[str] = None, no_exists: Dict[int, Dict[int, NotExistMediaInfo]] = None, diff --git a/app/chain/subscribe.py b/app/chain/subscribe.py index 572bbc59..1ca42d44 100644 --- a/app/chain/subscribe.py +++ b/app/chain/subscribe.py @@ -24,6 +24,7 @@ from app.db.models.subscribe import Subscribe from app.db.site_oper import SiteOper from app.db.subscribe_oper import SubscribeOper from app.db.systemconfig_oper import SystemConfigOper +from app.helper.memory import memory_optimized from app.helper.subscribe import SubscribeHelper from app.helper.torrent import TorrentHelper from app.log import logger @@ -267,6 +268,7 @@ class SubscribeChain(ChainBase): return True return False + @memory_optimized(force_gc_after=True, log_memory=True) def search(self, sid: Optional[int] = None, state: Optional[str] = 'N', manual: Optional[bool] = False): """ 订阅搜索 @@ -538,6 +540,7 @@ class SubscribeChain(ChainBase): return ret_sites + @memory_optimized(force_gc_after=True, log_memory=True) def match(self, torrents: Dict[str, List[Context]]): """ 从缓存中匹配订阅,并自动下载 diff --git a/app/chain/transfer.py b/app/chain/transfer.py index e5910e60..99dbfb96 100755 --- a/app/chain/transfer.py +++ b/app/chain/transfer.py @@ -25,6 +25,7 @@ from app.db.systemconfig_oper import SystemConfigOper from app.db.transferhistory_oper import TransferHistoryOper from app.helper.directory import DirectoryHelper from app.helper.format import FormatParser +from app.helper.memory import memory_optimized from app.helper.progress import ProgressHelper from app.log import logger from app.schemas import TransferInfo, TransferTorrent, Notification, EpisodeFormat, FileItem, TransferDirectoryConf, \ @@ -937,6 +938,7 @@ class TransferChain(ChainBase, metaclass=Singleton): return trans_items + @memory_optimized(force_gc_after=True, log_memory=True) def do_transfer(self, fileitem: FileItem, meta: MetaBase = None, mediainfo: MediaInfo = None, target_directory: TransferDirectoryConf = None,