Update window title handling and ensure consistent version retrieval in configuration
Some checks failed
Tests & Quality Checks / Test on Python 3.11 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.10 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-2 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-2 (push) Has been cancelled
Tests & Quality Checks / Build Artifacts (push) Has been cancelled
Tests & Quality Checks / Build Artifacts-1 (push) Has been cancelled
Some checks failed
Tests & Quality Checks / Test on Python 3.11 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.10 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-2 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-2 (push) Has been cancelled
Tests & Quality Checks / Build Artifacts (push) Has been cancelled
Tests & Quality Checks / Build Artifacts-1 (push) Has been cancelled
This commit is contained in:
parent
e0b316fe65
commit
03991fdea5
2 changed files with 24 additions and 8 deletions
|
|
@ -137,7 +137,22 @@ class Config:
|
|||
log_file = Config.get_default_log_path()
|
||||
|
||||
app_name = data.get("app_name", "WebDrop Bridge")
|
||||
window_title = data.get("window_title", f"{app_name} v{__version__}")
|
||||
stored_window_title = data.get("window_title", "")
|
||||
|
||||
# Regenerate default window titles on version upgrade
|
||||
# If the stored title matches the pattern "{app_name} v{version}", regenerate it
|
||||
# with the current version. This ensures the title updates automatically on upgrades.
|
||||
import re
|
||||
version_pattern = re.compile(rf"^{re.escape(app_name)}\s+v[\d.]+$")
|
||||
if stored_window_title and version_pattern.match(stored_window_title):
|
||||
# Detected a default-pattern title with old version, regenerate
|
||||
window_title = f"{app_name} v{__version__}"
|
||||
elif stored_window_title:
|
||||
# Custom window title, keep it as-is
|
||||
window_title = stored_window_title
|
||||
else:
|
||||
# No window title specified, use default
|
||||
window_title = f"{app_name} v{__version__}"
|
||||
|
||||
return cls(
|
||||
app_name=app_name,
|
||||
|
|
@ -178,12 +193,10 @@ class Config:
|
|||
|
||||
# Extract and validate configuration values
|
||||
app_name = os.getenv("APP_NAME", "WebDrop Bridge")
|
||||
# Version comes from __init__.py (lazy import to avoid circular imports)
|
||||
if not os.getenv("APP_VERSION"):
|
||||
# Version always comes from __init__.py for consistency
|
||||
from webdrop_bridge import __version__
|
||||
app_version = __version__
|
||||
else:
|
||||
app_version = os.getenv("APP_VERSION")
|
||||
|
||||
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
|
||||
log_file_str = os.getenv("LOG_FILE", None)
|
||||
allowed_roots_str = os.getenv("ALLOWED_ROOTS", "Z:/,C:/Users/Public")
|
||||
|
|
|
|||
|
|
@ -52,8 +52,11 @@ class TestConfigFromEnv:
|
|||
# Load config (env vars from file, not system)
|
||||
config = Config.from_env(str(env_file))
|
||||
|
||||
# Version always comes from package __init__.py, not from APP_VERSION env var
|
||||
from webdrop_bridge import __version__
|
||||
|
||||
assert config.app_name == "TestApp"
|
||||
assert config.app_version == "2.0.0"
|
||||
assert config.app_version == __version__ # Uses package version, not env var
|
||||
assert config.log_level == "DEBUG"
|
||||
assert config.allowed_roots == [root1.resolve(), root2.resolve()]
|
||||
assert config.allowed_urls == ["example.com", "*.test.org"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue