Add native Windows compatibility layer

This commit is contained in:
pewdiepie-archdaemon
2026-06-01 15:09:47 +09:00
parent ead7c01822
commit 0888a3b3e6
54 changed files with 1104 additions and 267 deletions

View File

@@ -996,7 +996,7 @@ def _migrate_assign_legacy_owner():
auth_path = os.path.join("data", "auth.json")
admin_user = None
try:
with open(auth_path, "r") as f:
with open(auth_path, "r", encoding="utf-8") as f:
auth_data = _json.load(f)
users = auth_data.get("users", {})
if users:
@@ -1067,12 +1067,12 @@ def _migrate_assign_legacy_owner():
prefs_path = os.path.join("data", "user_prefs.json")
try:
if os.path.exists(prefs_path):
with open(prefs_path, "r") as f:
with open(prefs_path, "r", encoding="utf-8") as f:
prefs = _json.load(f)
if "_users" not in prefs and prefs:
# Flat format → nest under admin user
new_prefs = {"_users": {admin_user: prefs}}
with open(prefs_path, "w") as f:
with open(prefs_path, "w", encoding="utf-8") as f:
_json.dump(new_prefs, f, indent=2)
logger.info(f"Migrated user_prefs.json to per-user format under '{admin_user}'")
except Exception as e:
@@ -1437,7 +1437,7 @@ def _migrate_seed_email_account():
if not settings_file.exists():
return
try:
s = _json.loads(settings_file.read_text())
s = _json.loads(settings_file.read_text(encoding="utf-8"))
except Exception:
return