Fix AttributeError when mediainfo.type is None

Co-authored-by: jxxghp <51039935+jxxghp@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-24 00:04:02 +00:00
parent 79710310ce
commit f3b910d55a
2 changed files with 3 additions and 3 deletions

View File

@@ -464,7 +464,7 @@ class FileManagerModule(_ModuleBase):
else:
# 未找到有效的媒体库目录
logger.error(
f"{mediainfo.type.value} {mediainfo.title_year} 未找到有效的媒体库目录,无法整理文件,源路径:{fileitem.path}")
f"{mediainfo.type.value if mediainfo.type else '未知类型'} {mediainfo.title_year} 未找到有效的媒体库目录,无法整理文件,源路径:{fileitem.path}")
return TransferInfo(success=False,
fileitem=fileitem,
message="未找到有效的媒体库目录")

View File

@@ -708,7 +708,7 @@ class TransHandler:
"""
获取目标路径
"""
if need_type_folder:
if need_type_folder and mediainfo.type:
target_path = target_path / mediainfo.type.value
if need_category_folder and mediainfo.category:
target_path = target_path / mediainfo.category
@@ -728,7 +728,7 @@ class TransHandler:
need_type_folder = target_dir.library_type_folder
if need_category_folder is None:
need_category_folder = target_dir.library_category_folder
if not target_dir.media_type and need_type_folder:
if not target_dir.media_type and need_type_folder and mediainfo.type:
# 一级自动分类
library_dir = Path(target_dir.library_path) / mediainfo.type.value
elif target_dir.media_type and need_type_folder: