diff --git a/src/voice_dictation/core/paths.py b/src/voice_dictation/core/paths.py index 3099f58..ecdd17a 100644 --- a/src/voice_dictation/core/paths.py +++ b/src/voice_dictation/core/paths.py @@ -3,10 +3,13 @@ from __future__ import annotations import os +import re import sys from dataclasses import dataclass from pathlib import Path +from voice_dictation import __version__ + @dataclass(frozen=True, slots=True) class AppPaths: @@ -40,8 +43,9 @@ class AppPaths: AppPaths с путями в ~/.dictate/. """ override = os.environ.get("VOICE_DICTATION_HOME") - beta = bool(getattr(sys, "frozen", False)) and any( - parent.name == "Voice Dictation Beta.app" for parent in Path(sys.executable).parents + # Build identity must survive renaming or moving the .app bundle. + beta = bool(getattr(sys, "frozen", False)) and bool( + re.search(r"(?:a|b|rc|\.dev)\d", __version__) ) root = ( Path(override).expanduser() diff --git a/tests/unit/test_local_pipeline.py b/tests/unit/test_local_pipeline.py index 8822bc1..0c96a6d 100644 --- a/tests/unit/test_local_pipeline.py +++ b/tests/unit/test_local_pipeline.py @@ -162,3 +162,14 @@ def test_checkpoint_model_change_is_rejected(tmp_paths): recording, Config(transcription_backend="local", local_model="whisper-small") ) orchestrator.shutdown() + + +def test_renamed_beta_bundle_still_cannot_use_production_profile(tmp_path, monkeypatch): + import sys + + monkeypatch.delenv("VOICE_DICTATION_HOME", raising=False) + monkeypatch.setattr(Path, "home", lambda: tmp_path) + monkeypatch.setattr(sys, "frozen", True, raising=False) + monkeypatch.setattr(sys, "executable", "/tmp/Renamed.app/Contents/MacOS/VoiceDictation") + assert AppPaths.default().root == tmp_path / ".dictate-beta" + assert AppPaths.default().pid_file != tmp_path / ".dictate/dictate.pid"