FIx unix branch in are_paths_equal

This commit is contained in:
Shupeng Xue 2024-06-23 06:01:22 +10:00
parent b6fc6f4a0e
commit ff8dbf3322
No known key found for this signature in database
GPG key ID: A6C508165D76B601

View file

@ -1,8 +1,7 @@
use std::{borrow::Cow, collections::{HashMap, VecDeque}, ffi::{OsStr, OsString}, fs::Metadata, path::{Path, PathBuf}}; use std::{borrow::Cow, collections::{HashMap, VecDeque}, ffi::{OsStr, OsString}, fs::Metadata, os::unix::fs::MetadataExt, path::{Path, PathBuf}};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use tokio::{fs, io, select, sync::{mpsc, oneshot}, time}; use tokio::{fs, io, select, sync::{mpsc, oneshot}, time};
use winapi_util::{file::information, Handle};
#[inline] #[inline]
pub async fn must_exists(p: impl AsRef<Path>) -> bool { fs::symlink_metadata(p).await.is_ok() } pub async fn must_exists(p: impl AsRef<Path>) -> bool { fs::symlink_metadata(p).await.is_ok() }
@ -35,6 +34,7 @@ pub async fn are_paths_equal(old: impl AsRef<Path>, new: impl AsRef<Path>) -> bo
} }
#[cfg(windows)] #[cfg(windows)]
{ {
use winapi_util::{file::information, Handle};
match (Handle::from_path_any(old), Handle::from_path_any(new)) { match (Handle::from_path_any(old), Handle::from_path_any(new)) {
(Ok(old), Ok(new)) => match (information(old), information(new)) { (Ok(old), Ok(new)) => match (information(old), information(new)) {
(Ok(old), Ok(new)) => { (Ok(old), Ok(new)) => {