Skip to content

fix: 保存路径支持空格(#447) - #519

Open
zzuu080603 wants to merge 1 commit into
ihmily:mainfrom
zzuu080603:fix/save-path-spaces
Open

zzuu080603 wants to merge 1 commit into
ihmily:mainfrom
zzuu080603:fix/save-path-spaces

Conversation

@zzuu080603

Copy link
Copy Markdown

📜 标题(Title)

  • 保存路径(含空格)不再被静默改写为下划线目录;自定义脚本改用参数列表传递,带空格的录像路径可作为单一参数到达脚本。

🔍 描述(Description)

问题 1:Linux/Docker 下保存路径的空格被改写(#447)
_get_save_path 中 sys.platform == 'linux' 时将整个输出目录的空格替换为下划线——用户配置 …/live live 会被静默录制到 …/live_live。ffmpeg 通过 argv 列表接收路径,空格在所有平台均合法,该改写无必要,已删除。文件名部分保留原有的下划线规范化(与本次 issue 无关的既定行为)。

问题 2:自定义脚本的"引号"从未生效(顺带修复,路径空格的必要配套)
原实现把参数拼进命令字符串(--save_file_path \"…\"),再由 run_script_async 用 command.split() 切分后交给 create_subprocess_exec(非 shell 执行):

  • 引号成为字面字符,脚本收到的参数值带引号;
  • 路径一旦含空格(本次放开后必然出现)会碎裂成多个参数。

现在 custom_script_execute 直接构建参数列表,run_script_async 接收列表(兼容旧字符串,经 shlex.split 解析),带空格路径作为单一参数传递。已用真实子进程探针端到端验证。

📝 类型(Type of Change)

  • 修复Bug
  • 新功能
  • 代码风格更新(格式化,局部变量)
  • 重构(改进代码结构)
  • 构建相关更改(依赖项,构建脚本等)
  • 其他:_ _

🏗️ 测试(Testing)

行为级验证(加载真实源码,11/11 通过):

  • _get_save_path('D:/live live/recordings') 目录部分保留空格;文件名空格仍规范化;分段后缀 _%03d.ts 正常
  • custom_script_execute(python/非 python 分支)产出 argv 列表:带空格保存路径为单一参数、无字面引号、--save_file_path 与值成对
  • 端到端:create_subprocess_exec + argv 列表执行子进程探针,确认收到完整的带空格路径参数
  • ruff 与语法编译通过

已知边界(与原版一致,非本次回归):自定义脚本命令本身含空格时仍会按空白切分,用户应使用无空格的脚本路径。

📋 检查清单(Checklist)

  • 我已经阅读贡献指南文档(仓库无独立 CONTRIBUTING.md,按 PR 模板执行)
  • 我的更改没有产生新的警告(ruff 通过)
  • 我已经添加了覆盖我更改的测试(11 项行为验证,含端到端子进程探针)
  • 我已经相应地更新了文档(如果适用)(无配置/界面变更)
  • 我遵循了这个项目的代码风格

Fixes #447

On Linux/Docker _get_save_path rewrote every space of the output
directory to an underscore, silently recording into a different,
underscore-named directory than the one the user configured. Spaces are
valid path characters everywhere (ffmpeg receives argv as a list), so
the rewrite is removed; the filename itself keeps the long-standing
underscore normalization.

Passing a spaced path through required also fixing the custom-script
plumbing, which only appeared to quote arguments: the command string was
split on whitespace and executed with create_subprocess_exec (no shell),
so quotes were literal characters and any spaced argument would shatter
into multiple argv entries. custom_script_execute now builds a real
argument list and run_script_async accepts a list (or a legacy string
via shlex), passing spaced paths as single arguments. Verified
end-to-end with a subprocess probe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛[BUG] 录像保存路径不支持空格, 希望解决!

1 participant