Keep beta profile isolated even when application bundle is renamed
This commit is contained in:
parent
96c5e95683
commit
c5bd2213c7
2 changed files with 17 additions and 2 deletions
|
|
@ -3,10 +3,13 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from voice_dictation import __version__
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, slots=True)
|
@dataclass(frozen=True, slots=True)
|
||||||
class AppPaths:
|
class AppPaths:
|
||||||
|
|
@ -40,8 +43,9 @@ class AppPaths:
|
||||||
AppPaths с путями в ~/.dictate/.
|
AppPaths с путями в ~/.dictate/.
|
||||||
"""
|
"""
|
||||||
override = os.environ.get("VOICE_DICTATION_HOME")
|
override = os.environ.get("VOICE_DICTATION_HOME")
|
||||||
beta = bool(getattr(sys, "frozen", False)) and any(
|
# Build identity must survive renaming or moving the .app bundle.
|
||||||
parent.name == "Voice Dictation Beta.app" for parent in Path(sys.executable).parents
|
beta = bool(getattr(sys, "frozen", False)) and bool(
|
||||||
|
re.search(r"(?:a|b|rc|\.dev)\d", __version__)
|
||||||
)
|
)
|
||||||
root = (
|
root = (
|
||||||
Path(override).expanduser()
|
Path(override).expanduser()
|
||||||
|
|
|
||||||
|
|
@ -162,3 +162,14 @@ def test_checkpoint_model_change_is_rejected(tmp_paths):
|
||||||
recording, Config(transcription_backend="local", local_model="whisper-small")
|
recording, Config(transcription_backend="local", local_model="whisper-small")
|
||||||
)
|
)
|
||||||
orchestrator.shutdown()
|
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"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue