fix 手动整理Bug

This commit is contained in:
jxxghp
2024-11-14 08:04:52 +08:00
parent fda11f427c
commit c12e2bdba7
5 changed files with 30 additions and 19 deletions

View File

@@ -48,15 +48,16 @@ class DirectoryHelper:
"""
return [d for d in self.get_library_dirs() if d.library_storage == "local"]
def get_dir(self, media: MediaInfo, src_path: Path = None, dest_path: Path = None,
fileitem: schemas.FileItem = None, local: bool = False) -> Optional[schemas.TransferDirectoryConf]:
def get_dir(self, media: MediaInfo, storage: str = "local",
src_path: Path = None, dest_path: Path = None, fileitem: schemas.FileItem = None
) -> Optional[schemas.TransferDirectoryConf]:
"""
根据媒体信息获取下载目录、媒体库目录配置
:param media: 媒体信息
:param storage: 存储类型
:param src_path: 源目录,有值时直接匹配
:param dest_path: 目标目录,有值时直接匹配
:param fileitem: 文件项,使用文件路径匹配
:param local: 是否本地目录
"""
# 处理类型
if not media:
@@ -66,6 +67,12 @@ class DirectoryHelper:
dirs = self.get_dirs()
# 按照配置顺序查找
for d in dirs:
# 没有启用整理的目录
if not d.monitor_type:
continue
# 存储类型不匹配
if storage and d.storage != storage:
continue
# 下载目录
download_path = Path(d.download_path)
# 媒体库目录
@@ -79,9 +86,6 @@ class DirectoryHelper:
# 有目标目录时,目标目录不匹配媒体库目录
if dest_path and not dest_path.is_relative_to(library_path):
continue
# 本地目录
if local and d.storage != "local":
continue
# 目录类型为全部的,符合条件
if not d.media_type:
return d