mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
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 491068a440
)
This commit is contained in:
parent
eede574723
commit
a81b287e7a
|
@ -62,21 +62,15 @@ KDirectoryContentsCounterWorker::CountResult walkDir(const QString &dirPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowedRecursiveLevel > 0) {
|
if (allowedRecursiveLevel > 0) {
|
||||||
|
|
||||||
bool linkFound = false;
|
|
||||||
QString nameBuf = QStringLiteral("%1/%2").arg(dirPath, dirEntry->d_name);
|
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 (QT_STAT(nameBuf.toLocal8Bit(), &buf) == 0) {
|
||||||
if (S_ISDIR(buf.st_mode)) {
|
|
||||||
// was a dir link, recurse
|
|
||||||
linkFound = true;
|
|
||||||
}
|
|
||||||
size += buf.st_size;
|
size += buf.st_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dirEntry->d_type == DT_DIR || linkFound) {
|
if (dirEntry->d_type == DT_DIR) {
|
||||||
// recursion for dirs and dir links
|
// recursion for dirs
|
||||||
size += walkDir(nameBuf, countHiddenFiles, countDirectoriesOnly, dirEntry, allowedRecursiveLevel - 1).size;
|
size += walkDir(nameBuf, countHiddenFiles, countDirectoriesOnly, dirEntry, allowedRecursiveLevel - 1).size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue