fix 7a5d2101
This commit is contained in:
parent
c147d36cb2
commit
dac718edc8
@ -603,7 +603,7 @@ class TransferChain(ChainBase):
|
|||||||
return
|
return
|
||||||
if path.is_file():
|
if path.is_file():
|
||||||
# 删除文件、nfo、jpg
|
# 删除文件、nfo、jpg
|
||||||
files = glob.glob(f"{Path(path.parent).joinpath(str(path.name).split('.')[0])}*")
|
files = glob.glob(f"{Path(path.parent).joinpath(path.stem)}*")
|
||||||
for file in files:
|
for file in files:
|
||||||
Path(file).unlink()
|
Path(file).unlink()
|
||||||
logger.warn(f"文件 {path} 已删除")
|
logger.warn(f"文件 {path} 已删除")
|
||||||
@ -620,8 +620,7 @@ class TransferChain(ChainBase):
|
|||||||
# 需要删除父目录
|
# 需要删除父目录
|
||||||
|
|
||||||
# 判断当前媒体父路径下是否有媒体文件,如有则无需遍历父级
|
# 判断当前媒体父路径下是否有媒体文件,如有则无需遍历父级
|
||||||
files = SystemUtils.list_files(path.parent, settings.RMT_MEDIAEXT)
|
if not SystemUtils.exits_files(path.parent, settings.RMT_MEDIAEXT):
|
||||||
if not files:
|
|
||||||
# 媒体库二级分类根路径
|
# 媒体库二级分类根路径
|
||||||
library_root_names = [
|
library_root_names = [
|
||||||
settings.LIBRARY_MOVIE_NAME or '电影',
|
settings.LIBRARY_MOVIE_NAME or '电影',
|
||||||
|
@ -106,7 +106,7 @@ class SystemUtils:
|
|||||||
|
|
||||||
if directory.is_file():
|
if directory.is_file():
|
||||||
return [directory]
|
return [directory]
|
||||||
|
|
||||||
if not min_filesize:
|
if not min_filesize:
|
||||||
min_filesize = 0
|
min_filesize = 0
|
||||||
|
|
||||||
@ -122,6 +122,36 @@ class SystemUtils:
|
|||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def exits_files(directory: Path, extensions: list, min_filesize: int = 0) -> bool:
|
||||||
|
"""
|
||||||
|
判断目录下是否存在指定扩展名的文件
|
||||||
|
:return True存在 False不存在
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not min_filesize:
|
||||||
|
min_filesize = 0
|
||||||
|
|
||||||
|
if not directory.exists():
|
||||||
|
return False
|
||||||
|
|
||||||
|
if directory.is_file():
|
||||||
|
return True
|
||||||
|
|
||||||
|
if not min_filesize:
|
||||||
|
min_filesize = 0
|
||||||
|
|
||||||
|
pattern = r".*(" + "|".join(extensions) + ")$"
|
||||||
|
|
||||||
|
# 遍历目录及子目录
|
||||||
|
for path in directory.rglob('**/*'):
|
||||||
|
if path.is_file() \
|
||||||
|
and re.match(pattern, path.name, re.IGNORECASE) \
|
||||||
|
and path.stat().st_size >= min_filesize * 1024 * 1024:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_sub_files(directory: Path, extensions: list) -> List[Path]:
|
def list_sub_files(directory: Path, extensions: list) -> List[Path]:
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user