]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Don't recurse into symlinks when counting directory contents
authorFabian Vogt <fabian@ritter-vogt.de>
Mon, 2 Jan 2023 13:53:42 +0000 (14:53 +0100)
committerFabian Vogt <fabian@ritter-vogt.de>
Mon, 9 Jan 2023 15:21:31 +0000 (16:21 +0100)
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)

src/kitemviews/private/kdirectorycontentscounterworker.cpp

index 49ee92e66dfef8b16cbe2a28833de14e6b0f11a4..9b86cd702a0177b47d138fd9d5fa7b9f6d5bb77d 100644 (file)
@@ -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;
                 }
             }