fix #96
This commit is contained in:
parent
51b30e8e63
commit
9c0c7e8497
@ -2,11 +2,12 @@ import gc
|
||||
import pickle
|
||||
import traceback
|
||||
from abc import ABCMeta
|
||||
from msilib.schema import File
|
||||
from pathlib import Path
|
||||
from typing import Optional, Any, Tuple, List, Set, Union, Dict
|
||||
|
||||
from qbittorrentapi import TorrentFilesList
|
||||
from ruamel.yaml import CommentedMap
|
||||
from transmission_rpc import File
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.context import Context
|
||||
@ -308,7 +309,7 @@ class ChainBase(metaclass=ABCMeta):
|
||||
"""
|
||||
return self.run_module("stop_torrents", hashs=hashs)
|
||||
|
||||
def torrent_files(self, tid: str) -> Optional[List[File]]:
|
||||
def torrent_files(self, tid: str) -> Optional[Union[TorrentFilesList, List[File]]]:
|
||||
"""
|
||||
根据种子文件,选择并添加下载任务
|
||||
:param tid: 种子Hash
|
||||
|
@ -1,5 +1,4 @@
|
||||
import re
|
||||
from msilib.schema import File
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Tuple, Set, Dict, Union
|
||||
|
||||
@ -624,13 +623,3 @@ class DownloadChain(ChainBase):
|
||||
删除下载任务
|
||||
"""
|
||||
return self.remove_torrents(hashs=[hash_str])
|
||||
|
||||
def get_files(self, tid: str) -> Optional[List[File]]:
|
||||
"""
|
||||
获取种子文件清单
|
||||
"""
|
||||
try:
|
||||
return self.torrent_files(tid=tid)
|
||||
except Exception as err:
|
||||
logger.error(f"获取种子文件列表出错:{err}")
|
||||
return None
|
||||
|
@ -1,6 +1,7 @@
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import threading
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Union
|
||||
|
||||
@ -19,6 +20,8 @@ from app.schemas.types import TorrentStatus, EventType, MediaType, ProgressKey,
|
||||
from app.utils.string import StringUtils
|
||||
from app.utils.system import SystemUtils
|
||||
|
||||
lock = threading.Lock()
|
||||
|
||||
|
||||
class TransferChain(ChainBase):
|
||||
"""
|
||||
@ -52,6 +55,8 @@ class TransferChain(ChainBase):
|
||||
else:
|
||||
return None, None
|
||||
|
||||
# 全局锁,避免重复处理
|
||||
with lock:
|
||||
if arg_str:
|
||||
logger.info(f"开始转移下载器文件,参数:{arg_str}")
|
||||
# 解析中种子hash,TMDB ID
|
||||
|
@ -1,7 +1,8 @@
|
||||
from msilib.schema import File
|
||||
from pathlib import Path
|
||||
from typing import Set, Tuple, Optional, Union, List
|
||||
|
||||
from qbittorrentapi import TorrentFilesList
|
||||
|
||||
from app import schemas
|
||||
from app.core.config import settings
|
||||
from app.core.metainfo import MetaInfo
|
||||
@ -188,7 +189,7 @@ class QbittorrentModule(_ModuleBase):
|
||||
"""
|
||||
return self.qbittorrent.start_torrents(ids=hashs)
|
||||
|
||||
def torrent_files(self, tid: str) -> Optional[List[File]]:
|
||||
def torrent_files(self, tid: str) -> Optional[TorrentFilesList]:
|
||||
"""
|
||||
获取种子文件列表
|
||||
"""
|
||||
|
@ -1,9 +1,8 @@
|
||||
import time
|
||||
from msilib.schema import File
|
||||
from typing import Optional, Union, Tuple, List
|
||||
|
||||
import qbittorrentapi
|
||||
from qbittorrentapi import TorrentDictionary
|
||||
from qbittorrentapi import TorrentDictionary, TorrentFilesList
|
||||
from qbittorrentapi.client import Client
|
||||
from qbittorrentapi.transfer import TransferInfoDictionary
|
||||
|
||||
@ -266,7 +265,7 @@ class Qbittorrent(metaclass=Singleton):
|
||||
logger.error(f"删除种子出错:{err}")
|
||||
return False
|
||||
|
||||
def get_files(self, tid: str) -> Optional[List[File]]:
|
||||
def get_files(self, tid: str) -> Optional[TorrentFilesList]:
|
||||
"""
|
||||
获取种子文件清单
|
||||
"""
|
||||
|
@ -1,7 +1,8 @@
|
||||
from msilib.schema import File
|
||||
from pathlib import Path
|
||||
from typing import Set, Tuple, Optional, Union, List
|
||||
|
||||
from transmission_rpc import File
|
||||
|
||||
from app import schemas
|
||||
from app.core.config import settings
|
||||
from app.core.metainfo import MetaInfo
|
||||
|
@ -715,7 +715,7 @@ class MediaSyncDel(_PluginBase):
|
||||
logger.info(f"{history_key} 转种时未删除源下载任务,开始删除源下载任务…")
|
||||
|
||||
try:
|
||||
dl_files = self.chain.get_files(tid=torrent_hash)
|
||||
dl_files = self.chain.torrent_files(tid=torrent_hash)
|
||||
if not dl_files:
|
||||
logger.info(f"未获取到 {settings.DOWNLOADER} - {torrent_hash} 种子文件,种子已被删除")
|
||||
else:
|
||||
@ -736,7 +736,7 @@ class MediaSyncDel(_PluginBase):
|
||||
# 如果是False则说明种子文件没有完全被删除,暂停种子,暂不处理
|
||||
if delete_flag:
|
||||
try:
|
||||
dl_files = self.chain.get_files(tid=download_id)
|
||||
dl_files = self.chain.torrent_files(tid=download_id)
|
||||
if not dl_files:
|
||||
logger.info(f"未获取到 {download} - {download_id} 种子文件,种子已被删除")
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user