mirror of https://github.com/zkat/cacache-rs.git
fix: clippy io_other_error
This commit is contained in:
parent
1ff3cee535
commit
81fe1309db
|
|
@ -187,7 +187,7 @@ impl AsyncWriter {
|
||||||
})))))
|
})))))
|
||||||
}
|
}
|
||||||
_ => Err(Error::IoError(
|
_ => Err(Error::IoError(
|
||||||
std::io::Error::new(std::io::ErrorKind::Other, "temp file create error"),
|
std::io::Error::other("temp file create error"),
|
||||||
"Possible memory issues for file handle".into(),
|
"Possible memory issues for file handle".into(),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
|
@ -496,20 +496,18 @@ fn make_mmap(tmpfile: &mut NamedTempFile, size: Option<usize>) -> Result<Option<
|
||||||
#[cfg(feature = "mmap")]
|
#[cfg(feature = "mmap")]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn allocate_file(file: &std::fs::File, size: usize) -> std::io::Result<()> {
|
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;
|
use std::os::fd::AsRawFd;
|
||||||
|
|
||||||
let fd = file.as_raw_fd();
|
let fd = file.as_raw_fd();
|
||||||
match unsafe { libc::posix_fallocate64(fd, 0, size as i64) } {
|
match unsafe { libc::posix_fallocate64(fd, 0, size as i64) } {
|
||||||
0 => Ok(()),
|
0 => Ok(()),
|
||||||
libc::ENOSPC => Err(Error::new(
|
libc::ENOSPC => Err(Error::other(
|
||||||
ErrorKind::Other, // ErrorKind::StorageFull is unstable
|
|
||||||
"cannot allocate file: no space left on device",
|
"cannot allocate file: no space left on device",
|
||||||
)),
|
)),
|
||||||
err => Err(Error::new(
|
err => Err(Error::other(format!(
|
||||||
ErrorKind::Other,
|
"posix_fallocate64 failed with code {err}"
|
||||||
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 {
|
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