Uncached and cached results for readdir were inconsistent -- the former returned correct stat info for directory entries while the latter didn't. That's because only names of entries were saved in cache without stat info. In turn this leads to issues like
https://github.com/junegunn/fzf/issues/3832 since directory traversal library (https://github.com/charlievieth/fastwalk in this case) relies on proper stat info returned by readdir. Hence when unchached result was returned it gave proper outcome, while with cached result it was wrong.
Cache stat info next to entry name to fix the issue. While file attributes are saved in cache already, they use full path as key. To avoid potentially plenty of allocations, string copying and cache lookups to get each attr, let's keep a copy of stat struct independently to be on the fast path.
Uncached and cached results for readdir were inconsistent -- the former returned correct stat info for directory entries while the latter didn't. That's because only names of entries were saved in cache without stat info. In turn this leads to issues like https://github.com/junegunn/fzf/issues/3832 since directory traversal library (https://github.com/charlievieth/fastwalk in this case) relies on proper stat info returned by readdir. Hence when unchached result was returned it gave proper outcome, while with cached result it was wrong.
Cache stat info next to entry name to fix the issue. While file attributes are saved in cache already, they use full path as key. To avoid potentially plenty of allocations, string copying and cache lookups to get each attr, let's keep a copy of stat struct independently to be on the fast path.