┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Vogt <[email protected]>2023-01-02 14:53:42 +0100
committerFabian Vogt <[email protected]>2023-01-09 16:21:31 +0100
commita81b287e7af7db24ff26a659fe599e5a8b290bd1 (patch)
treedc05d86a3ab7987df31907d80e19f7b87625221c
parenteede5747237ac736340b01ad5b913f479011ddff (diff)
Don't recurse into symlinks when counting directory contents
Symlink contents should not be visited for the purpose of displaying sizes. Not only is potentially misleading because the storage is actually used elsewhere (the target location), it can be completely wrong as contents can be visited multiple times, even recursively. BUG: 434125 (cherry picked from commit 491068a4405f93ce66d4f49fa5ba5dee29e9546b)
-rw-r--r--src/kitemviews/private/kdirectorycontentscounterworker.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/kitemviews/private/kdirectorycontentscounterworker.cpp b/src/kitemviews/private/kdirectorycontentscounterworker.cpp
index 49ee92e66..9b86cd702 100644
--- a/src/kitemviews/private/kdirectorycontentscounterworker.cpp
+++ b/src/kitemviews/private/kdirectorycontentscounterworker.cpp
@@ -62,21 +62,15 @@ KDirectoryContentsCounterWorker::CountResult walkDir(const QString &dirPath,
}
if (allowedRecursiveLevel > 0) {
-
- bool linkFound = false;
QString nameBuf = QStringLiteral("%1/%2").arg(dirPath, dirEntry->d_name);
- if (dirEntry->d_type == DT_REG || dirEntry->d_type == DT_LNK) {
+ if (dirEntry->d_type == DT_REG) {
if (QT_STAT(nameBuf.toLocal8Bit(), &buf) == 0) {
- if (S_ISDIR(buf.st_mode)) {
- // was a dir link, recurse
- linkFound = true;
- }
size += buf.st_size;
}
}
- if (dirEntry->d_type == DT_DIR || linkFound) {
- // recursion for dirs and dir links
+ if (dirEntry->d_type == DT_DIR) {
+ // recursion for dirs
size += walkDir(nameBuf, countHiddenFiles, countDirectoriesOnly, dirEntry, allowedRecursiveLevel - 1).size;
}
}