Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to MapHide are documented here.

## [v0.3.1](https://github.com/ColorDumper/MapHide/compare/v0.3.0...v0.3.1) - 2026-11-19

### Fixed

- Fixed Update saying the download didn't finish on some PCs, often ones with a fairly new Windows install. ([3d1f422](https://github.com/ColorDumper/MapHide/commit/3d1f422cd326f6cf711792151fac1e69bca92c0d))
- Fixed update checks telling you to check your internet connection when the real problem was your PC's date and time, or GitHub's certificate. ([3d1f422](https://github.com/ColorDumper/MapHide/commit/3d1f422cd326f6cf711792151fac1e69bca92c0d))
- Fixed the debug log leaving out why an update check or download failed. ([3d1f422](https://github.com/ColorDumper/MapHide/commit/3d1f422cd326f6cf711792151fac1e69bca92c0d))
- Fixed the message for an empty OBS Source Name in Settings naming a field that doesn't exist. ([2f81494](https://github.com/ColorDumper/MapHide/commit/2f814943f7fc5de2a29412248d0073461a6de91f))
- Fixed settings being saved in MapHide's own folder, instead of your AppData folder, on a PC where Windows doesn't say where AppData is. ([3c54deb](https://github.com/ColorDumper/MapHide/commit/3c54deba75e8cdf574034c2876dbad9bf8d123a2))

## [v0.3.0](https://github.com/ColorDumper/MapHide/compare/v0.2.6...v0.3.0) - 2026-11-13

### Added
Expand Down
2 changes: 1 addition & 1 deletion maphide/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def config_from_form(
hide_hotkey = str(hide_hotkey).strip().upper()

if not scene_item_name:
raise ValueError("Overlay Source is required.")
raise ValueError("OBS Source Name is required.")
if not is_valid_show_hotkey(hotkey):
raise ValueError(SHOW_KEY_HELP)
if toggle_mode and not is_valid_hide_hotkey(hide_hotkey):
Expand Down
13 changes: 12 additions & 1 deletion maphide/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@
# entry point are in the parent directory.
APP_DIR = Path(__file__).resolve().parent.parent
APP_NAME = "MapHide"
CONFIG_DIR = Path(os.getenv("APPDATA", APP_DIR)) / APP_NAME


def config_dir(environ=os.environ, home=Path.home):
"""MapHide's settings folder, in the user's AppData\\Roaming. Found from
the home folder when the APPDATA variable is missing, so settings never
land in the program's own folder."""
appdata = environ.get("APPDATA")
root = Path(appdata) if appdata else home() / "AppData" / "Roaming"
return root / APP_NAME


CONFIG_DIR = config_dir()
CONFIG_PATH = CONFIG_DIR / "config.json"
LEGACY_CONFIG_PATH = APP_DIR / "config.json"
ICON_ICO_PATH = APP_DIR / "MapHide.ico"
Expand Down
52 changes: 43 additions & 9 deletions maphide/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import json
import os
import re
import ssl
import subprocess
import sys
import tempfile
Expand All @@ -21,6 +22,9 @@
from dataclasses import dataclass
from pathlib import Path

import truststore

from .logs import describe_exception, logger
from .version import CHANNEL, CHANNEL_GITHUB, CHANNEL_SOURCE, VERSION

REPO = "ColorDumper/MapHide"
Expand All @@ -46,6 +50,12 @@
DOWNLOAD_DAMAGED = "The download was damaged. Try again."
INSTALLER_DIDNT_START = "The installer couldn't start."
CHECK_FAILED = "Couldn't check for updates."
CLOCK_WRONG = "Your PC's date and time look wrong. Fix them in Windows settings and try again."
CERTIFICATE_REFUSED = "Windows couldn't confirm the connection to GitHub is safe. Try again later."

# Certificate errors that usually mean the PC's clock is wrong: Windows'
# "outside its validity period", and OpenSSL's "not yet valid" and "expired".
CLOCK_ERROR_CODES = frozenset({0x800B0101, 9, 10})

# Updater states.
IDLE = "idle"
Expand Down Expand Up @@ -115,8 +125,26 @@ def redirect_request(self, req, fp, code, msg, headers, newurl):
return super().redirect_request(req, fp, code, msg, headers, newurl)


def _https_context():
"""Windows checks GitHub's certificates, as it does for a browser. It
then fetches a trusted root it doesn't have yet, which a fairly new
Windows may be missing, instead of the connection being refused."""
return truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)


# How MapHide goes online: https only, redirects included.
OPENER = urllib.request.build_opener(HttpsOnlyRedirects())
OPENER = urllib.request.build_opener(
urllib.request.HTTPSHandler(context=_https_context()), HttpsOnlyRedirects()
)


def _certificate_message(exc):
"""What to tell the user when `exc` is a certificate being refused, or
None when it's something else."""
reason = getattr(exc, "reason", exc)
if not isinstance(reason, ssl.SSLCertVerificationError):
return None
return CLOCK_WRONG if reason.verify_code in CLOCK_ERROR_CODES else CERTIFICATE_REFUSED


def _request(url):
Expand All @@ -140,9 +168,9 @@ def fetch_latest(opener=OPENER.open):
# too many checks from this network in the last hour.
raise UpdateError(GITHUB_UNAVAILABLE) from exc
except (urllib.error.URLError, TimeoutError, ConnectionError) as exc:
raise UpdateError(NO_CONNECTION) from exc
raise UpdateError(_certificate_message(exc) or NO_CONNECTION) from exc
except (ValueError, OSError) as exc:
raise UpdateError(UNEXPECTED_REPLY) from exc
raise UpdateError(_certificate_message(exc) or UNEXPECTED_REPLY) from exc
return release_from_json(data)


Expand Down Expand Up @@ -178,7 +206,7 @@ def download_setup(release, folder, progress=None, opener=OPENER.open):
raise
except (urllib.error.URLError, TimeoutError, OSError) as exc:
partial.unlink(missing_ok=True)
raise UpdateError(DOWNLOAD_FAILED) from exc
raise UpdateError(_certificate_message(exc) or DOWNLOAD_FAILED) from exc
return target


Expand Down Expand Up @@ -333,18 +361,24 @@ def _set(self, state, message=""):
self.message = message
self._on_change()

def _run(self, work, on_done):
def _run(self, step, work, on_done):
"""Run `work()` off the window's thread, then `on_done(result,
error)` back on it."""
error)` back on it. `step` names it in the debug log."""
outcome = []

def run():
try:
outcome.append((work(), None))
except UpdateError as exc:
# The window shows the plain message; the debug log gets
# what actually went wrong.
logger.warning(
"Update %s failed: %s", step, describe_exception(exc.__cause__ or exc)
)
outcome.append((None, str(exc)))
except Exception:
except Exception as exc:
# A bug here must still end the wait in the window.
logger.error("Update %s failed: %s", step, describe_exception(exc))
outcome.append((None, CHECK_FAILED))

def wait():
Expand Down Expand Up @@ -385,7 +419,7 @@ def work():
self._clean(self._folder)
return self._fetch()

self._run(work, done)
self._run("check", work, done)
return True

def clear_latest(self):
Expand Down Expand Up @@ -418,5 +452,5 @@ def done(_result, error):

self.progress = 0.0
self._set(DOWNLOADING)
self._run(work, done)
self._run("download", work, done)
return True
2 changes: 1 addition & 1 deletion maphide/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from .paths import APP_DIR

VERSION = "0.3.0"
VERSION = "0.3.1"
APP_VERSION = f"v{VERSION}"

# Where a packaged copy came from. The build writes one of these into
Expand Down
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ shiboken6==6.12.0 \
--hash=sha256:da382e68f0815b31b6dc2bce11a465b148c4f42c37b91546a361de1576567d10 \
--hash=sha256:ff72a72b3277b418902d562b987b33a6f6818bed9fe40a49d634d09bc67f620e
# via pyside6-essentials
truststore==0.10.5 \
--hash=sha256:30d36967ccaded5cbb38d602c433f53600036c79d502f4533a49b60a03bbefcd \
--hash=sha256:9aaaedaefaf06d8b206278cf8b5012bc897f485a874503501e12d776df78951c
# via -r requirements.in
websocket-client==1.9.2 \
--hash=sha256:0fcb57545848be86992e128218fd96dd87a6769ffdb1a968dff79632b85604d0 \
--hash=sha256:e1a673830a9c7bfa47b1cd3d5e4178f4c9651d80a4eab02c9c23a1c3ec6250ce
Expand Down
3 changes: 3 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ websocket-client==1.9.2
# The window and tray icon. Essentials is the core of Qt without the
# extra modules MapHide doesn't use.
PySide6-Essentials==6.12.0
# Lets Windows check GitHub's certificates for update checks and downloads,
# so a trusted root Windows hasn't downloaded yet is fetched, not refused.
truststore==0.10.5
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ shiboken6==6.12.0 \
--hash=sha256:da382e68f0815b31b6dc2bce11a465b148c4f42c37b91546a361de1576567d10 \
--hash=sha256:ff72a72b3277b418902d562b987b33a6f6818bed9fe40a49d634d09bc67f620e
# via pyside6-essentials
truststore==0.10.5 \
--hash=sha256:30d36967ccaded5cbb38d602c433f53600036c79d502f4533a49b60a03bbefcd \
--hash=sha256:9aaaedaefaf06d8b206278cf8b5012bc897f485a874503501e12d776df78951c
# via -r requirements.in
websocket-client==1.9.2 \
--hash=sha256:0fcb57545848be86992e128218fd96dd87a6769ffdb1a968dff79632b85604d0 \
--hash=sha256:e1a673830a9c7bfa47b1cd3d5e4178f4c9651d80a4eab02c9c23a1c3ec6250ce
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def test_a_filled_in_form_becomes_settings():
[
("host", " ", "OBS Host is required."),
("port", "", "OBS Port is required."),
("scene_item_name", "", "Overlay Source is required."),
("scene_item_name", "", "OBS Source Name is required."),
("hotkey", "ESC", "Show key supports A-Z."),
("port", "44a5", "OBS Port must be a number."),
("port", "0", "OBS Port must be between 1 and 65535."),
Expand Down
20 changes: 20 additions & 0 deletions tests/test_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Tests for where MapHide keeps its settings."""

from pathlib import Path

import pytest

from maphide.paths import config_dir


def test_settings_live_in_the_appdata_folder():
folder = config_dir({"APPDATA": r"C:\Users\Someone\AppData\Roaming"})

assert folder == Path(r"C:\Users\Someone\AppData\Roaming\MapHide")


@pytest.mark.parametrize("environ", [{}, {"APPDATA": ""}])
def test_without_appdata_settings_still_go_to_appdata_roaming(environ):
folder = config_dir(environ, home=lambda: Path(r"C:\Users\Someone"))

assert folder == Path(r"C:\Users\Someone\AppData\Roaming\MapHide")
Loading