169 Commits

Author SHA1 Message Date
Andrew Gallant
8e757b15d1 readme: document MSRV policy 2020-01-11 12:23:58 -05:00
Andrew Gallant
7c7013259e
2.2.9 2.2.9 2019-07-20 13:37:12 -04:00
Andrew Gallant
30e91a74e2 bug: fastidiously increment oldest_opened
A somewhat recent change permitted the `push` function to exit early
after `oldest_opened` was incremented, but before a new entry was pushed
on to the stack. Specifically, the only way this could happen was if
a handle could not be opened to an ancestor path, on Windows only. We
fix this by incrementing `oldest_opened` only after we push a new entry
to the stack.

Credit goes to @LukasKalbertodt for figuring out this bug!
2019-07-20 13:37:00 -04:00
Lukas Kalbertodt
7e0754a898 bug: fix use of skip_current_dir
The method sometimes destroyed an internal invariant by not decreasing
`oldest_opened`. That then leads to panics in `push`. We fix this by
calling the canonical `pop` function, which is what should have happened
from the beginning.

This includes a regression test that fails without this fix.

Fixes #118, Closes #124
2019-07-20 13:37:00 -04:00
Andrew Gallant
e09ce1cc51 internals: re-arrange implementation
This moves the DirEntry and Error types out into their own separate
modules.

This is prep work to (hopefully) make the impending refactoring (or
more likely, rewrite) more palatable.
2019-07-20 13:37:00 -04:00
Andrew Gallant
4235b6357c tests: rewrite them
This gets rid of a lot of unnecessary infrastructure around maintaining
the directory hierarchy in a tree. This was principally used in order to
support effective quickcheck tests, but since we dropped quickcheck, we
no longer need such things.

We know center tests around the Dir type, which makes setting up the
tests simpler and easier to understand.
2019-07-20 13:37:00 -04:00
Andrew Gallant
011973f170 tests: restructure them
This is in preparation to rewrite the tests.
2019-07-20 13:37:00 -04:00
Andrew Gallant
5d16163ce6 deps: drop quickcheck and rand
These weren't carrying their weight. Depending on rand is super
annoying, so just stop doing it. In particular, we can bring back the
minimal version check.
2019-07-20 13:37:00 -04:00
Andrew Gallant
526d70b165 list: add new walkdir-list binary
This supplants the previous "example" which was more like a debugging
program. So this commit not only rewrites it (dropping docopt in the
process in favor of clap), but moves it to its own non-published binary
crate.
2019-07-20 13:37:00 -04:00
Andrew Gallant
8deb700720 deps: bump rand and quickcheck
... to 0.6 and 0.8, respectively.

We aren't running tests on the MSRV any more any way, so we might as
well keep on moving.

Unfortunately, the rand ecosystem refuses to advertise and maintain
correct minimal versions in their Cargo.toml, so we have to remove the
minimal version check.
2019-07-20 13:37:00 -04:00
Andrew Gallant
f85554d459
2.2.8 2.2.8 2019-06-09 09:28:49 -04:00
Andrew Gallant
4eb176fc7a
style: allow bare trait objects
Because we aren't ready to bump our MSRV yet.
2019-06-09 09:27:57 -04:00
Andrew Gallant
b0809eee88
ci: remove minimal version check
Because rand. Sigh.
2019-06-09 09:27:36 -04:00
Andrew Gallant
71c5437f9c
deps: update rand to 0.6 2019-06-09 09:27:19 -04:00
Igor Gnatenko
a457894880
deps: update quickcheck to 0.8 2019-06-09 09:25:23 -04:00
Andrew Gallant
b8bdc069fd
cleanup: remove unused files from the old days 2019-05-01 13:32:43 -04:00
Guillaume Gomez
4c4fdb2abd test: check examples in README
PR #119
2019-05-01 10:52:20 -04:00
Andrew Gallant
830fc25acf
ci: stop testing on MSRV, build only 2019-04-30 13:32:15 -04:00
Andrew Gallant
45deac4d7e
code: remove unnecessary mut 2019-04-30 13:30:48 -04:00
Andrew Gallant
705d06c15d
2.2.7 2.2.7 2018-11-11 09:37:20 -05:00
Andrew Gallant
83b7a24302
walkdir: fix root symlink bug
This commit fixes a nasty bug where the root path given to walkdir was
always reported as a symlink, even when 'follow_links' was enabled. This
appears to be a regression introduced by commit 6f72fce as part of
fixing BurntSushi/ripgrep#984.

The central problem was that since root paths should always be followed,
we were creating a DirEntry whose internal file type was always resolved
by following a symlink, but whose 'metadata' method still returned the
metadata of the symlink and not the target. This was problematic and
inconsistent both with and without 'follow_links' enabled.

We also fix the documentation. In particular, we make the docs of 'new'
more unambiguous, where it previously could have been interpreted as
contradictory to the docs on 'DirEntry'. Specifically, 'WalkDir::new'
says:

    If root is a symlink, then it is always followed.

But the docs for 'DirEntry::metadata' say

    This always calls std::fs::symlink_metadata.

    If this entry is a symbolic link and follow_links is enabled, then
    std::fs::metadata is called instead.

Similarly, 'DirEntry::file_type' said

    If this is a symbolic link and follow_links is true, then this
    returns the type of the target.

That is, if 'root' is a symlink and 'follow_links' is NOT enabled,
then the previous incorrect behavior resulted in 'DirEntry::file_type'
behaving as if 'follow_links' was enabled. If 'follow_links'
was enabled, then the previous incorrect behavior resulted in
'DirEntry::metadata' reporting the metadata of the symlink itself.

We fix this by correctly constructing the DirEntry in the first place,
and then adding special case logic to path traversal that will always
attempt to follow the root path if it's a symlink and 'follow_links'
was not enabled. We also tweak the docs on 'WalkDir::new' to be more
precise.

Fixes #115
2018-11-11 09:32:29 -05:00
Andrew Gallant
4879ce266a
ci: pin to lazy_static 1.1 in CI 2018-11-07 07:17:55 -05:00
Andrew Gallant
99315723f5
2.2.6 2.2.6 2018-10-29 06:59:16 -04:00
Igor Gnatenko
809360416b ci: exclude CI files
PR #114
2018-10-29 06:58:59 -04:00
Andrew Gallant
e6fe17ca98
2.2.5 2.2.5 2018-08-25 10:46:35 -04:00
Andrew Gallant
80a08041e6
deps: update to quickcheck 0.7 2018-08-25 10:46:33 -04:00
Andrew Gallant
07a38b2948
2.2.4 2.2.4 2018-08-24 23:38:31 -04:00
Andrew Gallant
8b72d93227 windows: replace winapi ffi with winapi-util
We do still need winapi for a std-library work-around.
2018-08-24 23:38:09 -04:00
Andrew Gallant
64399797d1
2.2.3 2.2.3 2018-08-24 18:55:32 -04:00
Jacob Finkelman
ddf3f29717 deps: update for minimal-versions
PR #112
2018-08-24 18:55:24 -04:00
Andrew Gallant
edea9ea2d4
2.2.2 2.2.2 2018-08-22 20:47:51 -04:00
Aron Griffis
9a29218ca6 walkdir: add option to stay on same file system
This commit includes a new method, `same_file_system`, which when
enabled, will cause walkdir to only descend into directories that are on
the same file system as the root path.

Closes #8, Closes #107
2018-08-22 20:46:56 -04:00
Andrew Gallant
ddbbe48d56
DirEntry: add into_path method
This can avoid an allocation and copy in iterator chains that need to
produce a PathBuf.

PR #100
2018-08-22 18:46:58 -04:00
Andrew Gallant
987642ce46
2.2.1 2.2.1 2018-08-21 21:49:16 -04:00
Andrew Gallant
6f72fce431
path_is_symlink: fix false positive
This commit fixes a bug where the first path always reported itself as
as symlink via `path_is_symlink`.

Partially fixes https://github.com/BurntSushi/ripgrep/issues/984
2018-08-21 21:41:48 -04:00
Andrew Gallant
7033d12ded
deps: update docopt to 1.0 2018-08-21 21:30:51 -04:00
Andrew Gallant
dbe269c9af
2.2.0 2.2.0 2018-08-04 22:44:37 -04:00
Andrew Gallant
19f24b860e
msrv: bump minimum Rust to 1.23
lazy_static increased there's, so we might as we do ours.
2018-08-04 22:44:04 -04:00
Andrew Gallant
4b21b55f21
redox: remove uses of Unix-only things
The code for `cfg(not(any(unix, windows)))` is untested and contained a few
errors that this commit cleans up.
2018-06-13 12:13:02 -04:00
Jeremy Soller
40d2f56b94 Fix compilation on Redox 2018-06-13 09:47:37 -06:00
Jędrzej
e1f7637cf8 doc: use syntax highlighting in README 2018-05-27 08:59:26 -04:00
Ruud van Asseldonk
73eb575162 add DirEntry::into_path
This can avoid an allocation and copy in iterator chains that need to
produce a PathBuf.
2018-04-09 23:38:40 +02:00
Andrew Gallant
26dc0f584b
2.1.4 2.1.4 2018-02-20 19:24:27 -05:00
Andrew Gallant
ddac44a82a performance: fix regression
This commit fixes a performance regression introduced in commit 0f4441,
which aimed to fix OneDrive traversals. In particular, we added an
additional stat call to every directory entry, which can be quite
disastrous for performance. We fix this by being more fastidious about
reusing the Metadata that comes from fs::DirEntry, which is, conveniently,
cheap to acquire specifically on Windows.

The performance regression was reported against ripgrep:
https://github.com/BurntSushi/ripgrep/issues/820
2018-02-20 19:24:05 -05:00
Andrew Gallant
e3223962fe compile: clean up cfgs
In some cases, we were relying on things like "not(unix)" to mean "windows"
or "not(windows)" to mean "unix". Instead, we should split this in three
cases: unix, windows or not(unix or windows).
2018-02-20 19:24:05 -05:00
Michael Lamparski
44a5dfe6f7 doc: improve stdout in contents_first example
A big potential question on the reader's mind when reviewing these
docs is "what will the paths returned by the iterator be relative
to?" This is the one example on the page which shows output that
could potentially answer that question, and to only see filenames is
needlessly discouraging.
2018-02-10 13:35:49 -05:00
Andrew Gallant
aa8b1544f5
2.1.3 2.1.3 2018-02-01 22:50:59 -05:00
Andrew Gallant
2863f281e7
windows: more carefuly is_dir checking
This fixes a bug where a symlink was followed even if the user did not
request it. Namely, on Windows, a symlink can be interpreted as both a
symlink and a directory, given our new is_dir checking.
2018-02-01 22:50:55 -05:00
Andrew Gallant
dc4c1ccea1
windows: use entry file type
Using fs::metadata will always read through a link, and we want to
preserve the type of the original entry.
2018-02-01 22:49:59 -05:00
Andrew Gallant
01ee572ab4
gitignore: add tmp dir 2018-02-01 22:49:07 -05:00