mirror of https://github.com/zkat/cacache-rs.git
fix: clippy io_other_error
This commit is contained in:
parent
4b9fc3b5b7
commit
a9f037bd40
|
|
@ -491,20 +491,18 @@ fn make_mmap(tmpfile: &mut NamedTempFile, size: Option<usize>) -> Result<Option<
|
|||
#[cfg(feature = "mmap")]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn allocate_file(file: &std::fs::File, size: usize) -> std::io::Result<()> {
|
||||
use std::io::{Error, ErrorKind};
|
||||
use std::io::Error;
|
||||
use std::os::fd::AsRawFd;
|
||||
|
||||
let fd = file.as_raw_fd();
|
||||
match unsafe { libc::posix_fallocate64(fd, 0, size as i64) } {
|
||||
0 => Ok(()),
|
||||
libc::ENOSPC => Err(Error::new(
|
||||
ErrorKind::Other, // ErrorKind::StorageFull is unstable
|
||||
libc::ENOSPC => Err(Error::other(
|
||||
"cannot allocate file: no space left on device",
|
||||
)),
|
||||
err => Err(Error::new(
|
||||
ErrorKind::Other,
|
||||
format!("posix_fallocate64 failed with code {err}"),
|
||||
)),
|
||||
err => Err(Error::other(format!(
|
||||
"posix_fallocate64 failed with code {err}"
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,5 +59,5 @@ impl<T> IoErrorExt<T> for std::result::Result<T, serde_json::Error> {
|
|||
}
|
||||
|
||||
pub fn io_error(err: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> std::io::Error {
|
||||
std::io::Error::new(std::io::ErrorKind::Other, err)
|
||||
std::io::Error::other(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue