Add native Windows compatibility for config, bootstrap, and CLI.
Support profile-based config resolution with auto-selection of a sole profile, native IPA.exe -n bootstrap on Windows, platform-aware process cleanup, and Windows-friendly userdata backup path inference. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import shutil
|
||||
import tarfile
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from tempfile import NamedTemporaryFile
|
||||
from typing import Any, Callable
|
||||
|
||||
from .fsutil import sha256_file
|
||||
@@ -62,25 +61,24 @@ def backup_userdata(instance: str, instance_path: Path, state_root: Path) -> dic
|
||||
}
|
||||
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
manifest_path = destination.parent / f".{destination.name}.manifest.json"
|
||||
manifest_path.write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
with tarfile.open(destination, "w:gz") as archive:
|
||||
archive.add(source, arcname="UserData")
|
||||
with NamedTemporaryFile("w", encoding="utf-8", suffix=".json") as handle:
|
||||
json.dump(manifest, handle, indent=2, sort_keys=True)
|
||||
handle.write("\n")
|
||||
handle.flush()
|
||||
archive.add(handle.name, arcname="manifest.json")
|
||||
archive.add(manifest_path, arcname="manifest.json")
|
||||
manifest_path.unlink(missing_ok=True)
|
||||
return {"archive": str(destination), "manifest": manifest}
|
||||
|
||||
|
||||
def infer_windows_appdata_path(instance_path: Path) -> Path:
|
||||
parts = instance_path.resolve().parts
|
||||
try:
|
||||
users_index = parts.index("Users")
|
||||
bsmanager_index = parts.index("BSManager")
|
||||
except ValueError as exc:
|
||||
raise ValueError(f"cannot infer Windows user profile from instance path: {instance_path}") from exc
|
||||
if users_index + 1 >= len(parts):
|
||||
if bsmanager_index < 2 or parts[bsmanager_index - 2] != "Users":
|
||||
raise ValueError(f"cannot infer Windows user profile from instance path: {instance_path}")
|
||||
profile = Path(*parts[: users_index + 2])
|
||||
profile = Path(*parts[:bsmanager_index])
|
||||
return profile / "AppData" / "LocalLow" / "Hyperbolic Magnetism" / "Beat Saber"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user