Skip to content

Commit 07b3840

Browse files
committed
refactor: 优化upload_asset的路径处理报错
1 parent 36f2f6c commit 07b3840

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

astrbot/core/platform/sources/kook/kook_client.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,12 @@ async def upload_asset(self, file_url: str | None) -> str:
372372
file_url = file_url.removeprefix("file://")
373373

374374
try:
375-
target_path = Path(file_url)
376-
target_path = target_path.resolve()
375+
target_path = Path(file_url).resolve()
377376
except Exception as exp:
378-
logger.error(
379-
f'[KOOK] 获取文件 "{target_path.as_posix()}" 绝对路径失败: "{exp}"'
380-
)
377+
logger.error(f'[KOOK] 获取文件 "{file_url}" 绝对路径失败: "{exp}"')
381378
raise FileNotFoundError(
382-
f'获取文件 "{target_path.name}" 绝对路径失败: "{exp}"'
383-
)
379+
f'获取文件 "{file_url}" 绝对路径失败: "{exp}"'
380+
) from exp
384381

385382
# 安全验证
386383
if not target_path.is_relative_to(ALLOWED_ASSETS_DIR):

0 commit comments

Comments
 (0)