This commit is contained in:
jxxghp
2023-08-21 18:05:17 +08:00
parent c82ab161d0
commit f02ac2eaef
2 changed files with 16 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import shutil
from pathlib import Path
from typing import Set, Tuple, Optional, Union, List
@ -12,6 +13,7 @@ from app.modules.qbittorrent.qbittorrent import Qbittorrent
from app.schemas import TransferInfo, TransferTorrent, DownloadingTorrent
from app.schemas.types import TorrentStatus
from app.utils.string import StringUtils
from app.utils.system import SystemUtils
class QbittorrentModule(_ModuleBase):
@ -164,6 +166,12 @@ class QbittorrentModule(_ModuleBase):
if settings.TRANSFER_TYPE == "move":
if self.remove_torrents(hashs):
logger.info(f"移动模式删除种子成功:{hashs} ")
# 删除残留文件
if transinfo.path and transinfo.path.exists():
files = SystemUtils.list_files_with_extensions(transinfo.path, settings.RMT_MEDIAEXT)
if not files:
logger.warn(f"删除残留文件夹:{transinfo.path}")
shutil.rmtree(transinfo.path, ignore_errors=True)
def remove_torrents(self, hashs: Union[str, list]) -> bool:
"""

View File

@ -1,3 +1,4 @@
import shutil
from pathlib import Path
from typing import Set, Tuple, Optional, Union, List
@ -12,6 +13,7 @@ from app.modules.transmission.transmission import Transmission
from app.schemas import TransferInfo, TransferTorrent, DownloadingTorrent
from app.schemas.types import TorrentStatus
from app.utils.string import StringUtils
from app.utils.system import SystemUtils
class TransmissionModule(_ModuleBase):
@ -148,6 +150,12 @@ class TransmissionModule(_ModuleBase):
if settings.TRANSFER_TYPE == "move":
if self.remove_torrents(hashs):
logger.info(f"移动模式删除种子成功:{hashs} ")
# 删除残留文件
if transinfo.path and transinfo.path.exists():
files = SystemUtils.list_files_with_extensions(transinfo.path, settings.RMT_MEDIAEXT)
if not files:
logger.warn(f"删除残留文件夹:{transinfo.path}")
shutil.rmtree(transinfo.path, ignore_errors=True)
def remove_torrents(self, hashs: Union[str, list]) -> bool:
"""