fix(wine): select the client root that actually holds bin/ (#24)

* fix(wine): select the client root that actually holds bin/

`uur run` aborted with "WebView2 bootstrapper missing from the client
directory" on a complete install.

`find_client_dir` searched depth-first for `GameViewerServer.exe` and
returned the first hit, special-casing only a parent named `bin`. NetEase
ships the payload twice: as `<root>/bin/` and as a sibling
`<root>/<version>/`. When readdir order reached `<root>/<version>/` first,
that directory was returned as the client root. It has no `bin/`
subdirectory, so every `join("bin")` lookup missed -- the WebView2
bootstrapper and the terminal proxies -- and the session bailed out.
`deploy_terminal_proxy` then created a spurious `bin/` inside the version
directory and wrote proxies into it.

Now every directory holding `GameViewer.exe` is collected and ranked:
`bin/GameViewerServer.exe` scores highest because that is the layout uur
drives, then `bin/MicrosoftEdgeWebview2Setup.exe`, then a top-level
server. Ties break on path depth, then lexically, so the choice no longer
depends on readdir order. A versioned copy is still used when it is the
only candidate.

Adds four tests covering both layouts, readdir stability, and the
fallback.

* fix(wine): require complete payloads and support flat client layouts

---------

Co-authored-by: Xuc Pan <[email protected]>
This commit is contained in:
迢辰andXuc Pan authored and GitHub committed 2026-10-15 14:44:00 +08:00
1 parent 1dc156739c
commit bfecaa5c69
2 files changed
+220 -24

No files matched your search

+3 -4
View File
@@ -181,7 +181,7 @@ fn deploy_terminal_proxy(install_dir: &Path) -> Result<PathBuf> {
let source_dir = hook_source_dir()?;
let source = source_dir.join("uur-terminal-proxy.exe");
let mux_source = source_dir.join("uur-mux-proxy.exe");
let bin = install_dir.join("bin");
let bin = crate::wine::client_payload_dir(install_dir);
std::fs::create_dir_all(&bin)?;
for status in ["uur-terminal-adapter.status", "uur-mux-adapter.status"] {
let _ = std::fs::remove_file(bin.join(status));
@@ -254,9 +254,8 @@ fn ensure_webview2(prefix: &Path, install_dir: &Path) -> Result<()> {
if crate::wine::webview2_installed(prefix) {
return Ok(());
}
let bootstrapper = install_dir
.join("bin")
.join("MicrosoftEdgeWebview2Setup.exe");
let bootstrapper =
crate::wine::client_payload_dir(install_dir).join("MicrosoftEdgeWebview2Setup.exe");
if !bootstrapper.is_file() {
anyhow::bail!("{}", t!("session.webview_missing"));
}