Disable auto-delete when auto archive is turned off - #1
WarheadTaylor with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: WarheadTaylor <4128606+WarheadTaylor@users.noreply.github.com>
Co-authored-by: WarheadTaylor <4128606+WarheadTaylor@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Aligns runtime settings and OBS UI behavior so that disabling auto-archive also disables (and forces off) automatic deletion of the original recording, preventing “delete without an archive target” configurations.
Changes:
- Adds
disable_archivetoScriptSettingsand enforcesauto_delete_recordings=Falsein loaded settings when archive is disabled. - Updates the OBS script to (a) skip archive submission when disabled and (b) disable/uncheck the auto-delete UI control via a modified callback.
- Extends tests and updates README to document the coupled behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_settings.py | Imports ScriptSettings and adds a basic regression test for the new field. |
| tests/test_auto_record_games.py | Adds integration-style tests that load the OBS script with a stubbed obspython module to validate the new behavior. |
| src/obs_auto_record/settings.py | Adds disable_archive to the settings dataclass. |
| obs_scripts/auto_record_games.py | Introduces the new setting, enforces effective auto-delete behavior, adds UI callback, and skips archive submission when disabled. |
| README.md | Documents that disabling auto-archive also disables automatic deletion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| with patch.dict(sys.modules, {"obspython": obs_module}, clear=False), patch.object( | ||
| ctypes, | ||
| "WinDLL", | ||
| return_value=_FakeKernel32(), | ||
| create=True, | ||
| ): | ||
| sys.modules.pop(module_name, None) | ||
| sys.modules[module_name] = module | ||
| spec.loader.exec_module(module) |
There was a problem hiding this comment.
_load_script_module() imports obs_scripts/auto_record_games.py, which in turn imports obs_auto_record.process_scan while ctypes.WinDLL is patched. That leaves obs_auto_record.process_scan (and any other imported modules) cached in sys.modules with the fake WinDLL-backed globals after the context manager exits, which can leak into other tests in the same pytest process. Consider snapshotting/restoring the affected sys.modules entries (or explicitly removing obs_auto_record.process_scan / obs_auto_record.* from sys.modules in a finally) so this helper doesn’t contaminate the rest of the suite.
| with patch.dict(sys.modules, {"obspython": obs_module}, clear=False), patch.object( | |
| ctypes, | |
| "WinDLL", | |
| return_value=_FakeKernel32(), | |
| create=True, | |
| ): | |
| sys.modules.pop(module_name, None) | |
| sys.modules[module_name] = module | |
| spec.loader.exec_module(module) | |
| # Snapshot any existing obs_auto_record modules so we can restore them after importing | |
| # auto_record_games.py with a patched WinDLL. This prevents leaking fake WinDLL-backed | |
| # modules into other tests in the same process. | |
| _obs_auto_record_prefix = "obs_auto_record" | |
| _saved_obs_auto_record_modules = { | |
| name: m | |
| for name, m in sys.modules.items() | |
| if name == _obs_auto_record_prefix or name.startswith(_obs_auto_record_prefix + ".") | |
| } | |
| try: | |
| with patch.dict(sys.modules, {"obspython": obs_module}, clear=False), patch.object( | |
| ctypes, | |
| "WinDLL", | |
| return_value=_FakeKernel32(), | |
| create=True, | |
| ): | |
| sys.modules.pop(module_name, None) | |
| sys.modules[module_name] = module | |
| spec.loader.exec_module(module) | |
| finally: | |
| # Remove any obs_auto_record modules that were introduced during the patched import | |
| # and restore the previously saved ones. | |
| for name in list(sys.modules): | |
| if name == _obs_auto_record_prefix or name.startswith(_obs_auto_record_prefix + "."): | |
| if name not in _saved_obs_auto_record_modules: | |
| sys.modules.pop(name, None) | |
| for name, m in _saved_obs_auto_record_modules.items(): | |
| sys.modules[name] = m |
Disabling auto archive previously only skipped the archive copy;
Auto Delete Original Recordingcould remain enabled even though there was no archive target. This change makes those settings consistent by forcing auto delete off whenever auto archive is disabled.Settings behavior
disable_archiveas authoritative for archive-related side effectsauto_delete_recordings=Falsein the effective loaded settings when auto archive is disabledOBS script UI
Disable Auto ArchiveAuto Delete Original Recordingwhen archive disabling is enabledDocs
Auto Delete Original Recordingdisabled whenDisable Auto Archiveis enabled:💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.