summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <[email protected]>2025-07-08 13:45:52 -0700
committerThiago Macieira <[email protected]>2025-07-11 16:24:00 -0700
commitff5351b12f4dd6de1a96728859456aac556272af (patch)
tree8a3752e7d564d76125f947090107ba0548debe2c
parentf6211c079fa000c0d46b7912341f014669fa628a (diff)
QDirListing: check the flags before calling isSymLink()HEADdev
This delays potentially expensive FS checks until we know we need them. Task-number: QTBUG-138374 Fixes: QTBUG-134740 Pick-to: 6.10 6.9 6.8 Change-Id: I4a2f6e8c3713cc0033d7fffd5c75676be4e7e541 Reviewed-by: Ahmad Samir <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
-rw-r--r--src/corelib/io/qdirlisting.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/corelib/io/qdirlisting.cpp b/src/corelib/io/qdirlisting.cpp
index c626033dcdb..1fec92a01e2 100644
--- a/src/corelib/io/qdirlisting.cpp
+++ b/src/corelib/io/qdirlisting.cpp
@@ -510,16 +510,14 @@ bool QDirListingPrivate::matchesFilters(QDirEntryInfo &entryInfo) const
if (!iteratorFlags.testAnyFlag(F::IncludeHidden) && entryInfo.isHidden())
return false;
- if (entryInfo.isSymLink()) {
- // With ResolveSymlinks, we look at the type of the link's target,
- // and exclude broken symlinks (where the target doesn't exist).
- if (iteratorFlags.testAnyFlag(F::ResolveSymlinks)) {
- if (!entryInfo.exists())
- return false;
- } else if (iteratorFlags.testAnyFlags(F::FilesOnly)
- || iteratorFlags.testAnyFlags(F::DirsOnly)) {
- return false; // symlink is not a file or dir
- }
+ // With ResolveSymlinks, we look at the type of the link's target,
+ // and exclude broken symlinks (where the target doesn't exist).
+ if (iteratorFlags.testAnyFlag(F::ResolveSymlinks)) {
+ if (entryInfo.isSymLink() && !entryInfo.exists())
+ return false;
+ } else if ((iteratorFlags.testAnyFlags(F::FilesOnly)
+ || iteratorFlags.testAnyFlags(F::DirsOnly)) && entryInfo.isSymLink()) {
+ return false; // symlink is not a file or dir
}
if (iteratorFlags.testAnyFlag(F::ExcludeOther)