Repository navigation
feat(recording): 磁盘空间不足时自动清理旧录制文件(可配置开关) - #513
Open
LuckySauce wants to merge 2 commits into
Open
LuckySauce wants to merge 2 commits into
LuckySauce wants to merge 2 commits into
Conversation
- new utils.clean_old_recordings(): delete oldest recording files until the free-space threshold is met, protecting files modified within 10 minutes - check_free_space() now attempts auto-clean before disabling recording - new setting auto_clean_old_recordings (default off) with UI switch and zh_CN/en locales - tests for clean_old_recordings (5 cases)
…P041) Same fix as ihmily#512, needed here so this branch lints clean against main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 标题(Title)
🔍 描述(Description)
recording_space_threshold时会全局停止录制并弹出提示,但需要用户手动删除文件才能恢复。若录制期间长时间无人值守(如挂机录制),空间耗尽会导致录制中断。utils.clean_old_recordings():从录制目录递归收集视频/音频文件(mp4/flv/ts/mkv/aac/mp3/webm),按修改时间从旧到新删除,直到剩余空间恢复到阈值;10 分钟内修改过的文件一律跳过,保证正在录制或刚结束的文件不受影响。RecordingManager.check_free_space()挂接自动清理:空间不足且开关开启时先尝试清理并复查,清理后空间恢复则自动解除禁录;仍不足才维持原行为(禁录 + 提示)。auto_clean_old_recordings(默认关闭,行为不变),设置页在「录制空间剩余阈值」下方新增开关,附 zh_CN / en 双语文案与 tooltip。tests/test_disk_space.py共 5 个用例(空间充足不删、从旧到新删到达标、保护新文件、忽略非视频文件、递归子目录),mockshutil.disk_usage保证测试确定性。📝 类型(Type of Change)
🏗️ 测试(Testing)
python -m unittest discover -s tests -v:新增 5 个用例全部通过ruff check main.py app --config .ruff.toml:无新增错误(仅存量的 TRY400 与本次改动无关)ruff format --check main.py app:全部通过recording_space_threshold调高触发空间不足 → 开启开关后旧录制文件被从旧到新清理、录制自动恢复;关闭开关时行为与旧版一致