fix(qzone): 修复加载本地图片时未配置图片目录导致的潜在异常
在 `_load_local_images` 方法中,如果 `image_dir` 为 `None` 或空字符串,`os.path.exists` 会抛出 `TypeError`。本次修改增加了对 `image_dir` 变量本身的检查,确保在路径有效时才进行存在性判断,从而避免了因未配置图片目录而导致的程序崩溃。
This commit is contained in:
@@ -346,8 +346,8 @@ class QZoneService:
|
||||
def _load_local_images(self, image_dir: str) -> List[bytes]:
|
||||
"""随机加载本地图片(不删除文件)"""
|
||||
images = []
|
||||
if not os.path.exists(image_dir):
|
||||
logger.warning(f"图片目录不存在: {image_dir}")
|
||||
if not image_dir or not os.path.exists(image_dir):
|
||||
logger.warning(f"图片目录不存在或未配置: {image_dir}")
|
||||
return images
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user