16
16
from app .db .models .transferhistory import TransferHistory
17
17
from app .db .systemconfig_oper import SystemConfigOper
18
18
from app .db .transferhistory_oper import TransferHistoryOper
19
+ from app .helper .directory import DirectoryHelper
19
20
from app .helper .format import FormatParser
20
21
from app .helper .progress import ProgressHelper
21
22
from app .log import logger
@@ -41,6 +42,7 @@ def __init__(self):
41
42
self .mediachain = MediaChain ()
42
43
self .tmdbchain = TmdbChain ()
43
44
self .systemconfig = SystemConfigOper ()
45
+ self .directoryhelper = DirectoryHelper ()
44
46
45
47
def process (self ) -> bool :
46
48
"""
@@ -625,8 +627,7 @@ def send_transfer_message(self, meta: MetaBase, mediainfo: MediaInfo,
625
627
mtype = NotificationType .Organize ,
626
628
title = msg_title , text = msg_str , image = mediainfo .get_message_image ()))
627
629
628
- @staticmethod
629
- def delete_files (path : Path ) -> Tuple [bool , str ]:
630
+ def delete_files (self , path : Path ) -> Tuple [bool , str ]:
630
631
"""
631
632
删除转移后的文件以及空目录
632
633
:param path: 文件路径
@@ -657,16 +658,12 @@ def delete_files(path: Path) -> Tuple[bool, str]:
657
658
# 判断当前媒体父路径下是否有媒体文件,如有则无需遍历父级
658
659
if not SystemUtils .exits_files (path .parent , settings .RMT_MEDIAEXT ):
659
660
# 媒体库二级分类根路径
660
- library_root_names = [
661
- settings .LIBRARY_MOVIE_NAME or '电影' ,
662
- settings .LIBRARY_TV_NAME or '电视剧' ,
663
- settings .LIBRARY_ANIME_NAME or '动漫' ,
664
- ]
665
-
661
+ library_roots = self .directoryhelper .get_library_dirs ()
662
+ library_root_names = [Path (library_root .path ).name for library_root in library_roots if library_root .path ]
666
663
# 判断父目录是否为空, 为空则删除
667
664
for parent_path in path .parents :
668
665
# 遍历父目录到媒体库二级分类根路径
669
- if str ( parent_path .name ) in library_root_names :
666
+ if parent_path .name in library_root_names :
670
667
break
671
668
if str (parent_path .parent ) != str (path .root ):
672
669
# 父目录非根目录,才删除父目录
0 commit comments