cp: migrate from quick-error to thiserror (#7989)

* cp: migrate from quick-error to thiserror

fixes: #7916

* Remove quick-error

Now that we have migrated to thiserror, we can remove quick-error

* cp: fix test failures

* cp: fix fmt error
This commit is contained in:
Vikram Kangotra
2025-06-03 10:12:36 +02:00
committed by GitHub
parent 28612fe1f1
commit bfbdd5275d
9 changed files with 171 additions and 121 deletions
Generated
+1 -7
View File
@@ -1849,12 +1849,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "quick-error"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "quote"
version = "1.0.40"
@@ -2697,8 +2691,8 @@ dependencies = [
"indicatif",
"libc",
"linux-raw-sys",
"quick-error",
"selinux",
"thiserror 2.0.12",
"uucore",
"walkdir",
"xattr",
-1
View File
@@ -322,7 +322,6 @@ parse_datetime = "0.9.0"
phf = "0.11.2"
phf_codegen = "0.11.2"
platform-info = "2.0.3"
quick-error = "2.0.1"
rand = { version = "0.9.0", features = ["small_rng"] }
rand_core = "0.9.0"
rayon = "1.10"
+1 -1
View File
@@ -22,7 +22,6 @@ clap = { workspace = true }
filetime = { workspace = true }
libc = { workspace = true }
linux-raw-sys = { workspace = true }
quick-error = { workspace = true }
selinux = { workspace = true, optional = true }
uucore = { workspace = true, features = [
"backup-control",
@@ -37,6 +36,7 @@ uucore = { workspace = true, features = [
] }
walkdir = { workspace = true }
indicatif = { workspace = true }
thiserror = { workspace = true }
[target.'cfg(unix)'.dependencies]
xattr = { workspace = true }
+2 -2
View File
@@ -26,7 +26,7 @@ use uucore::uio_error;
use walkdir::{DirEntry, WalkDir};
use crate::{
CopyResult, Error, Options, aligned_ancestors, context_for, copy_attributes, copy_file,
CopyResult, CpError, Options, aligned_ancestors, context_for, copy_attributes, copy_file,
copy_link,
};
@@ -266,7 +266,7 @@ fn copy_direntry(
// TODO What other kinds of errors, if any, should
// cause us to continue walking the directory?
match err {
Error::IoErrContext(e, _) if e.kind() == io::ErrorKind::PermissionDenied => {
CpError::IoErrContext(e, _) if e.kind() == io::ErrorKind::PermissionDenied => {
show!(uio_error!(
e,
"cannot open {} for reading",
+148 -94
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -14,11 +14,11 @@ use std::os::unix::io::AsRawFd;
use std::path::Path;
use uucore::buf_copy;
use quick_error::ResultExt;
use uucore::mode::get_umask;
use crate::{CopyDebug, CopyResult, OffloadReflinkDebug, ReflinkMode, SparseDebug, SparseMode};
use crate::{
CopyDebug, CopyResult, CpError, OffloadReflinkDebug, ReflinkMode, SparseDebug, SparseMode,
};
/// The fallback behavior for [`clone`] on failed system call.
#[derive(Clone, Copy)]
@@ -404,7 +404,7 @@ pub(crate) fn copy_on_write(
return Err("`--reflink=always` can be used only with --sparse=auto".into());
}
};
result.context(context)?;
result.map_err(|e| CpError::IoErrContext(e, context.to_owned()))?;
Ok(copy_debug)
}
+6 -4
View File
@@ -9,11 +9,12 @@ use std::os::unix::ffi::OsStrExt;
use std::os::unix::fs::OpenOptionsExt;
use std::path::Path;
use quick_error::ResultExt;
use uucore::buf_copy;
use uucore::mode::get_umask;
use crate::{CopyDebug, CopyResult, OffloadReflinkDebug, ReflinkMode, SparseDebug, SparseMode};
use crate::{
CopyDebug, CopyResult, CpError, OffloadReflinkDebug, ReflinkMode, SparseDebug, SparseMode,
};
/// Copies `source` to `dest` using copy-on-write if possible.
///
@@ -104,14 +105,15 @@ pub(crate) fn copy_on_write(
let context = buf_copy::copy_stream(&mut src_file, &mut dst_file)
.map_err(|_| std::io::Error::from(std::io::ErrorKind::Other))
.context(context)?;
.map_err(|e| CpError::IoErrContext(e, context.to_owned()))?;
if source_is_fifo {
dst_file.set_permissions(src_file.metadata()?.permissions())?;
}
context
} else {
fs::copy(source, dest).context(context)?
fs::copy(source, dest)
.map_err(|e| CpError::IoErrContext(e, context.to_owned()))?
}
}
};
+4 -4
View File
@@ -6,9 +6,9 @@
use std::fs;
use std::path::Path;
use quick_error::ResultExt;
use crate::{CopyDebug, CopyResult, OffloadReflinkDebug, ReflinkMode, SparseDebug, SparseMode};
use crate::{
CopyDebug, CopyResult, CpError, OffloadReflinkDebug, ReflinkMode, SparseDebug, SparseMode,
};
/// Copies `source` to `dest` for systems without copy-on-write
pub(crate) fn copy_on_write(
@@ -31,7 +31,7 @@ pub(crate) fn copy_on_write(
reflink: OffloadReflinkDebug::Unsupported,
sparse_detection: SparseDebug::Unsupported,
};
fs::copy(source, dest).context(context)?;
fs::copy(source, dest).map_err(|e| CpError::IoErrContext(e, context.to_owned()))?;
Ok(copy_debug)
}
+5 -4
View File
@@ -7,11 +7,12 @@ use std::fs::{self, File, OpenOptions};
use std::os::unix::fs::OpenOptionsExt;
use std::path::Path;
use quick_error::ResultExt;
use uucore::buf_copy;
use uucore::mode::get_umask;
use crate::{CopyDebug, CopyResult, OffloadReflinkDebug, ReflinkMode, SparseDebug, SparseMode};
use crate::{
CopyDebug, CopyResult, CpError, OffloadReflinkDebug, ReflinkMode, SparseDebug, SparseMode,
};
/// Copies `source` to `dest` for systems without copy-on-write
pub(crate) fn copy_on_write(
@@ -48,7 +49,7 @@ pub(crate) fn copy_on_write(
buf_copy::copy_stream(&mut src_file, &mut dst_file)
.map_err(|_| std::io::Error::from(std::io::ErrorKind::Other))
.context(context)?;
.map_err(|e| CpError::IoErrContext(e, context.to_owned()))?;
if source_is_fifo {
dst_file.set_permissions(src_file.metadata()?.permissions())?;
@@ -56,7 +57,7 @@ pub(crate) fn copy_on_write(
return Ok(copy_debug);
}
fs::copy(source, dest).context(context)?;
fs::copy(source, dest).map_err(|e| CpError::IoErrContext(e, context.to_owned()))?;
Ok(copy_debug)
}