summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-08-21 20:22:08 -0400
committerAndrew Gallant <jamslam@gmail.com>2018-08-21 23:05:52 -0400
commit1529ce33414f33eb432f9efadf3e38609ae89429 (patch)
treef9883fcbc5bc4040d68a8ce4dac2d8cda1fc8302
parent95a4f15916699a1188f7b27c7eb71f850f404098 (diff)
ripgrep: remove workaround for std bug
This commit undoes a work-around for a bug in Rust's standard library that prevented correct file type detection on Windows in OneDrive directories. We remove the work-around because we are moving to a latest-stable Rust version policy, which has included this fix for a while now. ref #705, https://github.com/rust-lang/rust/issues/46484
-rw-r--r--ignore/src/walk.rs81
-rw-r--r--src/subject.rs25
2 files changed, 4 insertions, 102 deletions
diff --git a/ignore/src/walk.rs b/ignore/src/walk.rs
index 35b00066..8c2c35ee 100644
--- a/ignore/src/walk.rs
+++ b/ignore/src/walk.rs
@@ -216,19 +216,6 @@ impl DirEntryInner {
}
/// Returns true if and only if this entry points to a directory.
- ///
- /// This works around a bug in Rust's standard library:
- /// https://github.com/rust-lang/rust/issues/46484
- #[cfg(windows)]
- fn is_dir(&self) -> bool {
- self.metadata().map(|md| metadata_is_dir(&md)).unwrap_or(false)
- }
-
- /// Returns true if and only if this entry points to a directory.
- ///
- /// This works around a bug in Rust's standard library:
- /// https://github.com/rust-lang/rust/issues/46484
- #[cfg(not(windows))]
fn is_dir(&self) -> bool {
self.file_type().map(|ft| ft.is_dir()).unwrap_or(false)
}
@@ -253,10 +240,6 @@ struct DirEntryRaw {
ino: u64,
/// The underlying metadata (Windows only). We store this on Windows
/// because this comes for free while reading a directory.
- ///
- /// We use this to determine whether an entry is a directory or not, which
- /// works around a bug in Rust's standard library:
- /// https://github.com/rust-lang/rust/issues/46484
#[cfg(windows)]
metadata: fs::Metadata,
}
@@ -509,7 +492,7 @@ impl WalkBuilder {
(p.to_path_buf(), None)
} else {
let mut wd = WalkDir::new(p);
- wd = wd.follow_links(follow_links || path_is_file(p));
+ wd = wd.follow_links(follow_links || p.is_file());
if let Some(max_depth) = max_depth {
wd = wd.max_depth(max_depth);
}
@@ -776,7 +759,7 @@ impl Walk {
return false;
}
- let is_dir = walkdir_entry_is_dir(ent);
+ let is_dir = ent.file_type().is_dir();
let max_size = self.max_filesize;
let should_skip_path = skip_path(&self.ig, ent.path(), is_dir);
let should_skip_filesize = if !is_dir && max_size.is_some() {
@@ -805,7 +788,7 @@ impl Iterator for Walk {
}
Some((path, Some(it))) => {
self.it = Some(it);
- if path_is_dir(&path) {
+ if path.is_dir() {
let (ig, err) = self.ig_root.add_parents(path);
self.ig = ig;
if let Some(err) = err {
@@ -895,7 +878,7 @@ impl Iterator for WalkEventIter {
None => None,
Some(Err(err)) => Some(Err(err)),
Some(Ok(dent)) => {
- if walkdir_entry_is_dir(&dent) {
+ if dent.file_type().is_dir() {
self.depth += 1;
Some(Ok(WalkEvent::Dir(dent)))
} else {
@@ -1434,62 +1417,6 @@ fn skip_path(ig: &Ignore, path: &Path, is_dir: bool) -> bool {
}
}
-/// Returns true if and only if this path points to a directory.
-///
-/// This works around a bug in Rust's standard library:
-/// https://github.com/rust-lang/rust/issues/46484
-#[cfg(windows)]
-fn path_is_dir(path: &Path) -> bool {
- fs::metadata(path).map(|md| metadata_is_dir(&md)).unwrap_or(false)
-}
-
-/// Returns true if and only if this entry points to a directory.
-#[cfg(not(windows))]
-fn path_is_dir(path: &Path) -> bool {
- path.is_dir()
-}
-
-/// Returns true if and only if this path points to a file.
-///
-/// This works around a bug in Rust's standard library:
-/// https://github.com/rust-lang/rust/issues/46484
-#[cfg(windows)]
-fn path_is_file(path: &Path) -> bool {
- !path_is_dir(path)
-}
-
-/// Returns true if and only if this entry points to a directory.
-#[cfg(not(windows))]
-fn path_is_file(path: &Path) -> bool {
- path.is_file()
-}
-
-/// Returns true if and only if the given walkdir entry points to a directory.
-///
-/// This works around a bug in Rust's standard library:
-/// https://github.com/rust-lang/rust/issues/46484
-#[cfg(windows)]
-fn walkdir_entry_is_dir(dent: &walkdir::DirEntry) -> bool {
- dent.metadata().map(|md| metadata_is_dir(&md)).unwrap_or(false)
-}
-
-/// Returns true if and only if the given walkdir entry points to a directory.
-#[cfg(not(windows))]
-fn walkdir_entry_is_dir(dent: &walkdir::DirEntry) -> bool {
- dent.file_type().is_dir()
-}
-
-/// Returns true if and only if the given metadata points to a directory.
-///
-/// This works around a bug in Rust's standard library:
-/// https://github.com/rust-lang/rust/issues/46484
-#[cfg(windows)]
-fn metadata_is_dir(md: &fs::Metadata) -> bool {
- use std::os::windows::fs::MetadataExt;
- use winapi::um::winnt::FILE_ATTRIBUTE_DIRECTORY;
- md.file_attributes() & FILE_ATTRIBUTE_DIRECTORY != 0
-}
-
#[cfg(test)]
mod tests {
use std::fs::{self, File};
diff --git a/src/subject.rs b/src/subject.rs
index 61b34554..741b4fdd 100644
--- a/src/subject.rs
+++ b/src/subject.rs
@@ -172,36 +172,11 @@ impl Subject {
}
/// Returns true if and only if this subject points to a directory.
- ///
- /// This works around a bug in Rust's standard library:
- /// https://github.com/rust-lang/rust/issues/46484
- #[cfg(windows)]
- fn is_dir(&self) -> bool {
- use std::os::windows::fs::MetadataExt;
- use winapi::um::winnt::FILE_ATTRIBUTE_DIRECTORY;
-
- self.dent.metadata().map(|md| {
- md.file_attributes() & FILE_ATTRIBUTE_DIRECTORY != 0
- }).unwrap_or(false)
- }
-
- /// Returns true if and only if this subject points to a directory.
- #[cfg(not(windows))]
fn is_dir(&self) -> bool {
self.dent.file_type().map_or(false, |ft| ft.is_dir())
}
/// Returns true if and only if this subject points to a file.
- ///
- /// This works around a bug in Rust's standard library:
- /// https://github.com/rust-lang/rust/issues/46484
- #[cfg(windows)]
- fn is_file(&self) -> bool {
- !self.is_dir()
- }
-
- /// Returns true if and only if this subject points to a file.
- #[cfg(not(windows))]
fn is_file(&self) -> bool {
self.dent.file_type().map_or(false, |ft| ft.is_file())
}