mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
* Fix #728: fallback to copy when symlinking on windows * Signature hmm? * Squash warnings on windows * Just don’t use generics here
This commit is contained in:
parent
f2fc37eea5
commit
6bc1fb4983
3 changed files with 11 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
fmt, fs,
|
fmt,
|
||||||
path::{self, Component, Path, PathBuf},
|
path::{self, Component, Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ impl BinFile {
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fs::set_permissions(
|
std::fs::set_permissions(
|
||||||
&self.source,
|
&self.source,
|
||||||
std::os::unix::fs::PermissionsExt::from_mode(0o755),
|
std::os::unix::fs::PermissionsExt::from_mode(0o755),
|
||||||
)?;
|
)?;
|
||||||
|
|
|
@ -63,13 +63,15 @@ pub fn atomic_install(src: &Path, dst: &Path) -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
|
fn symlink_file(original: &Path, link: &Path) -> io::Result<()> {
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
let f = std::os::unix::fs::symlink;
|
std::os::unix::fs::symlink(original, link)?;
|
||||||
#[cfg(target_family = "windows")]
|
|
||||||
let f = std::os::windows::fs::symlink_file;
|
|
||||||
|
|
||||||
f(original, link)
|
// Symlinks on Windows are disabled in some editions, so creating one is unreliable.
|
||||||
|
#[cfg(target_family = "windows")]
|
||||||
|
std::os::windows::fs::symlink_file(original, link)
|
||||||
|
.or_else(|_| std::fs::copy(original, link).map(drop))?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Atomically install symlink "link" to a file "dst".
|
/// Atomically install symlink "link" to a file "dst".
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{future::pending, io};
|
use std::io;
|
||||||
|
|
||||||
use super::tasks::AutoAbortJoinHandle;
|
use super::tasks::AutoAbortJoinHandle;
|
||||||
use crate::errors::BinstallError;
|
use crate::errors::BinstallError;
|
||||||
|
@ -73,7 +73,7 @@ mod unix {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
// Use pending() here for the same reason as above.
|
// Use pending() here for the same reason as above.
|
||||||
pending().await
|
std::future::pending().await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue