From d818ceb8e6e162c307d3dbec269ed9f05ddde948 Mon Sep 17 00:00:00 2001 From: Attente <19653207+wikrin@users.noreply.github.com> Date: Sat, 2 Nov 2024 02:01:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=9C=A8?= =?UTF-8?q?=E6=9F=90=E4=BA=9B=E7=89=B9=E5=AE=9A=E5=9C=BA=E6=99=AF=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C`=E6=89=8B=E5=8A=A8=E6=95=B4=E7=90=86`=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AD=A3=E7=A1=AE=E8=8E=B7=E5=8F=96=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helper/directory.py | 6 +++++- app/modules/filemanager/__init__.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helper/directory.py b/app/helper/directory.py index 31ce5d8b..00570b82 100644 --- a/app/helper/directory.py +++ b/app/helper/directory.py @@ -49,12 +49,13 @@ 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, - local: bool = False) -> Optional[schemas.TransferDirectoryConf]: + fileitem: schemas.FileItem = None, local: bool = False) -> Optional[schemas.TransferDirectoryConf]: """ 根据媒体信息获取下载目录、媒体库目录配置 :param media: 媒体信息 :param src_path: 源目录,有值时直接匹配 :param dest_path: 目标目录,有值时直接匹配 + :param fileitem: 文件项,使用文件路径匹配 :param local: 是否本地目录 """ # 处理类型 @@ -76,6 +77,9 @@ class DirectoryHelper: if dest_path: if library_path != dest_path or not d.monitor_type: continue + # 没有目录配置时起作用, 通常处理`手动整理`未选择`目标目录`的情况 + if fileitem and not Path(fileitem.path).is_relative_to(download_path): + continue # 本地目录 if local and d.storage != "local": continue diff --git a/app/modules/filemanager/__init__.py b/app/modules/filemanager/__init__.py index 7d930658..75eaa8d7 100644 --- a/app/modules/filemanager/__init__.py +++ b/app/modules/filemanager/__init__.py @@ -326,7 +326,7 @@ class FileManagerModule(_ModuleBase): if target_path: target_directory = directoryhelper.get_dir(mediainfo, dest_path=target_path) else: - target_directory = directoryhelper.get_dir(mediainfo) + target_directory = directoryhelper.get_dir(mediainfo, fileitem=fileitem) if target_directory: # 拼装媒体库一、二级子目录