mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-05 22:52:02 -07:00
ignore: be fastidious with file handles
This commit fixes the symlink loop checker in the parallel directory
traverser to open fewer handles at the expense of keeping handles held
open longer.
This roughly matches the corresponding change in walkdir:
5bcc5b87ee
Fixes #633
This commit is contained in:
@@ -11,7 +11,7 @@ use std::time::Duration;
|
||||
use std::vec;
|
||||
|
||||
use crossbeam::sync::MsQueue;
|
||||
use same_file::is_same_file;
|
||||
use same_file::Handle;
|
||||
use walkdir::{self, WalkDir};
|
||||
|
||||
use dir::{Ignore, IgnoreBuilder};
|
||||
@@ -1308,11 +1308,11 @@ fn check_symlink_loop(
|
||||
child_path: &Path,
|
||||
child_depth: usize,
|
||||
) -> Result<(), Error> {
|
||||
let hchild = Handle::from_path(child_path).map_err(|err| {
|
||||
Error::from(err).with_path(child_path).with_depth(child_depth)
|
||||
})?;
|
||||
for ig in ig_parent.parents().take_while(|ig| !ig.is_absolute_parent()) {
|
||||
let same = try!(is_same_file(ig.path(), child_path).map_err(|err| {
|
||||
Error::from(err).with_path(child_path).with_depth(child_depth)
|
||||
}));
|
||||
if same {
|
||||
if ig.handle().map_or(true, |parent| parent == &hchild) {
|
||||
return Err(Error::Loop {
|
||||
ancestor: ig.path().to_path_buf(),
|
||||
child: child_path.to_path_buf(),
|
||||
|
Reference in New Issue
Block a user