mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
[yabridgectl] Use reflinks instead of copies
Whenever available. This should speed up the copying process while also reducing the amount of disk space wasted on Btrfs and XFS filesystems.
This commit is contained in:
Generated
+11
@@ -387,6 +387,16 @@ dependencies = [
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reflink"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc585ec28b565b4c28977ce8363a6636cedc280351ba25a7915f6c9f37f68cbe"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustyline"
|
||||
version = "6.3.0"
|
||||
@@ -625,6 +635,7 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"promptly",
|
||||
"rayon",
|
||||
"reflink",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"textwrap 0.11.0",
|
||||
|
||||
@@ -17,6 +17,7 @@ colored = "2.0.0"
|
||||
is_executable = "0.1.2"
|
||||
lazy_static = "1.4.0"
|
||||
promptly = "0.3.0"
|
||||
reflink = "0.1.3"
|
||||
rayon = "1.3.1"
|
||||
serde = "1.0.114"
|
||||
serde_derive = "1.0.114"
|
||||
|
||||
@@ -501,7 +501,7 @@ fn install_file(
|
||||
|
||||
match method {
|
||||
InstallationMethod::Copy => {
|
||||
utils::copy(from, to)?;
|
||||
utils::copy_or_reflink(from, to)?;
|
||||
}
|
||||
InstallationMethod::Symlink => {
|
||||
utils::symlink(from, to)?;
|
||||
|
||||
@@ -37,11 +37,12 @@ use crate::files::NativeFile;
|
||||
/// moment without causing issues.
|
||||
const YABRIDGE_HOST_EXPECTED_OUTPUT_PREFIX: &str = "Usage: yabridge-";
|
||||
|
||||
/// Wrapper around [`std::fs::copy()`](std::fs::copy) with a human readable error message.
|
||||
pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
|
||||
fs::copy(&from, &to).with_context(|| {
|
||||
/// Wrapper around [`reflink::reflink_or_copy()`](reflink::reflink_or_copy) with a human readable
|
||||
/// error message.
|
||||
pub fn copy_or_reflink<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<Option<u64>> {
|
||||
reflink::reflink_or_copy(&from, &to).with_context(|| {
|
||||
format!(
|
||||
"Error copying '{}' to '{}'",
|
||||
"Error reflinking '{}' to '{}'",
|
||||
from.as_ref().display(),
|
||||
to.as_ref().display()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user