fix: fix windows compile error

This commit is contained in:
shiro.lee
2024-12-24 22:51:50 +08:00
parent e725c97536
commit f08ec77a73
4 changed files with 14 additions and 94 deletions

85
Cargo.lock generated
View File

@@ -681,26 +681,6 @@ dependencies = [
"cipher",
]
[[package]]
name = "darwin-libproc"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fb90051930c9a0f09e585762152048e23ac74d20c10590ef7cf01c0343c3046"
dependencies = [
"darwin-libproc-sys",
"libc",
"memchr",
]
[[package]]
name = "darwin-libproc-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57cebb5bde66eecdd30ddc4b9cd208238b15db4982ccc72db59d699ea10867c1"
dependencies = [
"libc",
]
[[package]]
name = "deranged"
version = "0.3.11"
@@ -711,17 +691,6 @@ dependencies = [
"serde",
]
[[package]]
name = "derive_more"
version = "0.99.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "digest"
version = "0.10.7"
@@ -800,7 +769,7 @@ dependencies = [
"madmin",
"md-5",
"netif",
"nix 0.29.0",
"nix",
"num",
"num_cpus",
"path-absolutize",
@@ -1653,15 +1622,6 @@ dependencies = [
"hashbrown 0.12.3",
]
[[package]]
name = "mach2"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
dependencies = [
"libc",
]
[[package]]
name = "madmin"
version = "0.0.1"
@@ -1670,7 +1630,6 @@ dependencies = [
"common",
"humantime",
"hyper",
"psutil",
"serde",
"time",
"tracing",
@@ -1762,17 +1721,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "nix"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
dependencies = [
"bitflags 1.3.2",
"cfg-if",
"libc",
]
[[package]]
name = "nix"
version = "0.29.0"
@@ -2091,12 +2039,6 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "platforms"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94"
[[package]]
name = "poly1305"
version = "0.8.0"
@@ -2242,25 +2184,6 @@ dependencies = [
"tower 0.5.1",
]
[[package]]
name = "psutil"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e617cc9058daa5e1fe5a0d23ed745773a5ee354111dad1ec0235b0cc16b6730"
dependencies = [
"cfg-if",
"darwin-libproc",
"derive_more",
"glob",
"mach2",
"nix 0.24.3",
"num_cpus",
"once_cell",
"platforms",
"thiserror 1.0.69",
"unescape",
]
[[package]]
name = "quick-xml"
version = "0.37.1"
@@ -3338,12 +3261,6 @@ dependencies = [
"tz-rs",
]
[[package]]
name = "unescape"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6e"
[[package]]
name = "unicode-ident"
version = "1.0.14"

View File

@@ -44,6 +44,7 @@ use path_absolutize::Absolutize;
use std::collections::{HashMap, HashSet};
use std::fmt::Debug;
use std::io::Cursor;
#[cfg(target_family = "unix")]
use std::os::unix::fs::MetadataExt;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
@@ -963,7 +964,7 @@ impl DiskAPI for LocalDisk {
resp.results[i] = CHECK_PART_FILE_NOT_FOUND;
continue;
}
if (st.size() as usize) < fi.erasure.shard_file_size(part.size) {
if (st.len() as usize) < fi.erasure.shard_file_size(part.size) {
resp.results[i] = CHECK_PART_FILE_CORRUPT;
continue;
}

View File

@@ -1,6 +1,8 @@
#![allow(unsafe_code)] // TODO: audit unsafe code
use super::IOStats;
use crate::{disk::Info, error::Result};
use std::io::{Error, ErrorKind, Result};
use std::io::{Error, ErrorKind, Result as IoResult};
use std::mem;
use std::os::windows::ffi::OsStrExt;
use std::path::Path;
@@ -32,7 +34,7 @@ pub fn get_info(p: impl AsRef<Path>) -> Result<Info> {
)
};
if success == 0 {
return Err(Error::last_os_error());
return Err(Error::last_os_error().into());
}
let total = unsafe { *lp_total_number_of_bytes.QuadPart() };
@@ -47,7 +49,8 @@ pub fn get_info(p: impl AsRef<Path>) -> Result<Info> {
total,
p.as_ref().display()
),
));
)
.into());
}
let mut lp_sectors_per_cluster: DWORD = 0;
@@ -65,7 +68,7 @@ pub fn get_info(p: impl AsRef<Path>) -> Result<Info> {
)
};
if success == 0 {
return Err(Error::last_os_error());
return Err(Error::last_os_error().into());
}
Ok(Info {
@@ -87,7 +90,7 @@ fn get_volume_name(v: &[WCHAR]) -> Result<LPCWSTR> {
let success = unsafe { GetVolumePathNameW(v.as_ptr(), lp_volume_name_buffer.as_mut_ptr(), volume_name_size) };
if success == 0 {
return Err(Error::last_os_error());
return Err(Error::last_os_error().into());
}
Ok(lp_volume_name_buffer.as_ptr())
@@ -126,7 +129,7 @@ fn get_fs_type(p: &[WCHAR]) -> Result<String> {
};
if success == 0 {
return Err(Error::last_os_error());
return Err(Error::last_os_error().into());
}
Ok(utf16_to_string(&lp_file_system_name_buffer))
@@ -137,5 +140,5 @@ pub fn same_disk(disk1: &str, disk2: &str) -> Result<bool> {
}
pub fn get_drive_stats(major: u32, minor: u32) -> Result<IOStats> {
IOStats::default()
Ok(IOStats::default())
}

View File

@@ -14,7 +14,6 @@ chrono.workspace = true
common.workspace = true
humantime.workspace = true
hyper.workspace = true
psutil = "3.3.0"
serde.workspace = true
time.workspace =true
time.workspace = true
tracing.workspace = true