summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index af9b400..dc04ce0 100644
--- a/bftw.c
+++ b/bftw.c
@@ -889,8 +889,12 @@ const struct bfs_stat *bftw_stat(const struct BFTW *ftwbuf, enum bfs_stat_flags
const struct bfs_stat *bftw_cached_stat(const struct BFTW *ftwbuf, enum bfs_stat_flags flags) {
if (flags & BFS_STAT_NOFOLLOW) {
return ftwbuf->lstat_cache.buf;
- } else {
+ } else if (ftwbuf->stat_cache.buf) {
return ftwbuf->stat_cache.buf;
+ } else if ((flags & BFS_STAT_TRYFOLLOW) && is_nonexistence_error(ftwbuf->stat_cache.error)) {
+ return ftwbuf->lstat_cache.buf;
+ } else {
+ return NULL;
}
}