mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-442: remove junctions
review feedback IJCR-129069 GitOrigin-RevId: 5ee2799b901c3473ff8bf2826e7d4de1551a8af6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
aad1bb49b9
commit
047fda2dfd
Generated
-11
@@ -1922,16 +1922,6 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "junction"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca39ef0d69b18e6a2fd14c2f0a1d593200f4a4ed949b240b5917ab51fac754cb"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "krates"
|
||||
version = "0.15.3"
|
||||
@@ -3690,7 +3680,6 @@ dependencies = [
|
||||
"cargo-deny",
|
||||
"core-foundation",
|
||||
"jni",
|
||||
"junction",
|
||||
"libc",
|
||||
"libloading",
|
||||
"log",
|
||||
|
||||
@@ -48,8 +48,4 @@ cargo-about = "0.5.7" # generates license report
|
||||
winresource = "0.1.17"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.8.0"
|
||||
junction = "1.0.0"
|
||||
|
||||
[features]
|
||||
symlink_creation = []
|
||||
tempfile = "3.8.0"
|
||||
@@ -15,8 +15,6 @@ fn main() {
|
||||
fn main_os_specific() {
|
||||
println!("cargo:rustc-link-lib=legacy_stdio_definitions");
|
||||
|
||||
enable_symlinks_if_can_create_them();
|
||||
|
||||
let needs_metadata = std::env::var("XPLAT_LAUNCHER_EMBED_RESOURCES_AND_MANIFEST")
|
||||
.unwrap_or("0".to_string());
|
||||
|
||||
@@ -25,37 +23,6 @@ fn main_os_specific() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn enable_symlinks_if_can_create_them() {
|
||||
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||
let target = out_dir.join("target");
|
||||
if target.exists() {
|
||||
std::fs::remove_file(&target)
|
||||
.expect("Failed to delete target file")
|
||||
}
|
||||
|
||||
let contents = "test";
|
||||
std::fs::write(&target, contents)
|
||||
.expect("Unable to write to target file");
|
||||
|
||||
let link = out_dir.join("link");
|
||||
if link.exists() {
|
||||
// DeleteFile removes the symlink, and that's what is used
|
||||
std::fs::remove_file(&link)
|
||||
.expect("Failed to delete the link")
|
||||
}
|
||||
|
||||
match std::os::windows::fs::symlink_file(&target, &link) {
|
||||
Ok(_) => allow_symlink_creation(),
|
||||
Err(e) if e.raw_os_error() == Some(1314) => {
|
||||
println!(
|
||||
"Cannot use CreateSymbolicLink API, will use junction instead. File link creation will result in runtime errors."
|
||||
);
|
||||
},
|
||||
Err(e) => panic!("Failed to create symbolic link, but not due to the privileges: {:?}", e),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn embed_metadata() {
|
||||
let cargo_root_env_var = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
@@ -74,11 +41,5 @@ fn embed_metadata() {
|
||||
res.compile().expect("Failed to embed resource table and/or application manifest");
|
||||
}
|
||||
|
||||
fn allow_symlink_creation() {
|
||||
println!("cargo:rustc-cfg=feature=\"symlink_creation\"");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn main_os_specific() {
|
||||
allow_symlink_creation()
|
||||
}
|
||||
fn main_os_specific() { }
|
||||
@@ -384,26 +384,20 @@ fn symlink(original: &Path, link: &Path) -> Result<()> {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[cfg(feature = "symlink_creation")]
|
||||
fn symlink(original: &Path, link: &Path) -> Result<()> {
|
||||
if original.is_dir() {
|
||||
std::os::windows::fs::symlink_dir(original, link)
|
||||
} else {
|
||||
std::os::windows::fs::symlink_file(original, link)
|
||||
}
|
||||
.with_context(|| format!("Failed to create symlink {link:?} pointing to {original:?}"))
|
||||
}
|
||||
let result = match original.is_dir() {
|
||||
true => std::os::windows::fs::symlink_dir(original, link),
|
||||
false => std::os::windows::fs::symlink_file(original, link)
|
||||
};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[cfg(not(feature = "symlink_creation"))]
|
||||
fn symlink(original: &Path, link: &Path) -> Result<()> {
|
||||
if (original.is_file()) {
|
||||
bail!("symlink_creation feature is not enabled, can not use CreateSymbolicLink.\
|
||||
Consider having a privilege to do that or enabling Developer Mode");
|
||||
}
|
||||
let message = match &result {
|
||||
Ok(_) => "",
|
||||
Err(e) if e.raw_os_error() == Some(1314) => "can not use CreateSymbolicLink.\
|
||||
Consider having a privilege to do that or enabling Developer Mode",
|
||||
Err(_) => "failed to create symlink, but not due to privileges",
|
||||
};
|
||||
|
||||
junction::create(original, link)
|
||||
.with_context(|| format!("Failed to create symlink {link:?} pointing to {original:?}"))
|
||||
result.with_context(|| format!("Failed to create symlink {link:?} pointing to {original:?}; {message}"))
|
||||
}
|
||||
|
||||
pub fn get_custom_config_dir() -> PathBuf {
|
||||
|
||||
Reference in New Issue
Block a user