Revert "Fix #9584 - Using dirEntries and chdir() can have unwanted results (#10666)" #10718
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This essentially reverts commit 274109b.
It doesn’t remove the added unittest yet because it wonderfully underlines the point I’m going to make:
It adds no value.
The patch was a nerfed version of #6125. Well, it was nerfed to provide backwards compatibility. But this came at a cost: It no longer helped with the footgun imposed by relative paths that the original version did actually help with.
Let’s verify that Phobos still passes its testsuite and remove it for better (or worse).
Further thoughts
In addition it still failed to address the underlying problem that
DirEntry
-s that hold relative paths aren’t really aware of which directory they are relative to. That’s what needs to be fixed to resolve the UX issue at hand. I’ve spent quite a while hacking on the module and debugging my and existing code with my attempts at #10669 and #10706. The insight I’ve gained from this made it clear that any improvement implemented in this regard needs to be a thoroughly engineered one that doesn’t try to cut corners. I’ve also come to the conclusion that we still lack a proper unittest that doesn’t make premature assumptions; in particular one thing that prominent examples in the original issue report (and my later patches) got wrong is the expectation that we could just request the absolute path of aDirEntry
and get a accurate result independent of the current working directory. (I’m actually a bit surprised now that I could get ae555fb to pass CI tests.) The waystd.file
currently works, doesn’t provide any guarantees that could come close to fulfilling such a requirement yet. If we want to makeDirEntry
work with no dependency on the current working directory, we’ll need to overhaul the whole module accordingly. Otherwise users are still in for surprises like the one in #9584. FixingdirEntries
alone won’t provide a satisfactory result.