aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorHsiangNianian <i@jyunko.cn>2026-01-16 14:49:05 +0800
committerHsiangNianian <i@jyunko.cn>2026-01-16 14:49:05 +0800
commit1e0905613a7b7b98daf6dfecffa87fc0096a8e55 (patch)
tree121226072fe03735c95a177e012c9f7b1a987d95
parent0fbb2b7bbc9f69da3977f89fde3143c8f966b2c5 (diff)
downloadDropOut-1e0905613a7b7b98daf6dfecffa87fc0096a8e55.tar.gz
DropOut-1e0905613a7b7b98daf6dfecffa87fc0096a8e55.zip
feat: add UNC prefix stripping for Windows paths in Java handling
Implemented a helper function to strip the UNC prefix from file paths on Windows, ensuring cleaner path handling. Updated the Java candidate retrieval process to resolve symlinks and apply the new prefix stripping function, enhancing compatibility and usability on Windows systems.
-rw-r--r--src-tauri/src/core/java.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src-tauri/src/core/java.rs b/src-tauri/src/core/java.rs
index 7aa43b8..3f7a1e4 100644
--- a/src-tauri/src/core/java.rs
+++ b/src-tauri/src/core/java.rs
@@ -13,6 +13,18 @@ use crate::utils::zip;
const ADOPTIUM_API_BASE: &str = "https://api.adoptium.net/v3";
const CACHE_DURATION_SECS: u64 = 24 * 60 * 60; // 24 hours
+/// Helper to strip UNC prefix on Windows (\\?\)
+fn strip_unc_prefix(path: PathBuf) -> PathBuf {
+ #[cfg(target_os = "windows")]
+ {
+ let s = path.to_string_lossy().to_string();
+ if s.starts_with(r"\\?\") {
+ return PathBuf::from(&s[4..]);
+ }
+ }
+ path
+}
+
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JavaInstallation {
pub path: String,
@@ -649,7 +661,11 @@ fn get_java_candidates() -> Vec<PathBuf> {
for line in paths.lines() {
let path = PathBuf::from(line.trim());
if path.exists() {
- candidates.push(path);
+ // Resolve symlinks (important for Windows javapath wrapper)
+ let resolved = std::fs::canonicalize(&path).unwrap_or(path);
+ // Strip UNC prefix if present to keep paths clean
+ let final_path = strip_unc_prefix(resolved);
+ candidates.push(final_path);
}
}
}