fix: shell_exec 目录不存在时回落可写基础目录
This commit is contained in:
parent
1f848e0760
commit
48f5048df8
@ -393,6 +393,10 @@ async def shell_exec(command: str, workdir: str = None, timeout: int = 60):
|
||||
"""
|
||||
cwd = workdir or _resolve_workdir()
|
||||
cwd = os.path.abspath(cwd)
|
||||
# 如果指定目录不存在,回落到可写基础目录
|
||||
if not os.path.isdir(cwd):
|
||||
cwd = _resolve_workdir()
|
||||
cwd = os.path.abspath(cwd)
|
||||
base = os.path.abspath(_SHELL_BASE_DIR)
|
||||
fallback = os.path.abspath(_WORKDIR_FALLBACK)
|
||||
if not (cwd.startswith(base) or cwd.startswith(fallback)):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user