diff options
| author | Robert Hoffmann <[email protected]> | 2020-01-07 10:53:35 +0100 |
|---|---|---|
| committer | Robert Hoffmann <[email protected]> | 2020-01-11 21:59:12 +0100 |
| commit | 17e127edcd25f1fa62b1ac1940149763f88291fc (patch) | |
| tree | 98634e1a3785eac6321028d193729f41455faa10 | |
| parent | 09e215be4648a96e2daa5a9e5b6adc34ab444f16 (diff) | |
Add only canonical paths to dirWatcher
Summary: KDirWatch only works correctly with canonical paths, i.e. symbolic links resolved.
Test Plan:
1. Create dirs:
$ mkdir test1
$ mkdir test1/subdir
$ ln -s test1 test2
2. Start dolphin, navigate to test2/subdir, then in terminal:
$ echo test > test2/subdir/test
Without the patch, test2/subdir/test won't be shown automatically, only after reload (F5).
With the patch applied, test2/subdir/test will be shown automatically.
3. Restart dolphin, navigate to test2/subdir, then in terminal:
$ echo test >> test2/subdir/test
Without the patch, the increased size of test2/subdir/test won't be shown automatically,
only after reload (F5). With the patch applied, it will be shown automatically.
4. Restart dolphin, navigate to test2/subdir, then in terminal:
$ rm test2/subdir/test
Without the patch, test2/subdir/test stays visible, will only disappear after reload (F5).
With the patch applied, it will disappear automatically.
Reviewers: dfaure, #dolphin, elvisangelaccio
Reviewed By: dfaure, #dolphin, elvisangelaccio
Subscribers: ngraham, elvisangelaccio, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D25732
| -rw-r--r-- | src/kitemviews/private/kdirectorycontentscounter.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/kitemviews/private/kdirectorycontentscounter.cpp b/src/kitemviews/private/kdirectorycontentscounter.cpp index 977a83d5d..bd204fe8e 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.cpp +++ b/src/kitemviews/private/kdirectorycontentscounter.cpp @@ -23,6 +23,7 @@ #include <KDirWatch> +#include <QFileInfo> #include <QThread> KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObject* parent) : @@ -85,9 +86,11 @@ void KDirectoryContentsCounter::addDirectory(const QString& path) int KDirectoryContentsCounter::countDirectoryContentsSynchronously(const QString& path) { - if (!m_dirWatcher->contains(path)) { - m_dirWatcher->addDir(path); - m_watchedDirs.insert(path); + const QString resolvedPath = QFileInfo(path).canonicalFilePath(); + + if (!m_dirWatcher->contains(resolvedPath)) { + m_dirWatcher->addDir(resolvedPath); + m_watchedDirs.insert(resolvedPath); } KDirectoryContentsCounterWorker::Options options; @@ -107,9 +110,11 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count) { m_workerIsBusy = false; - if (!m_dirWatcher->contains(path)) { - m_dirWatcher->addDir(path); - m_watchedDirs.insert(path); + const QString resolvedPath = QFileInfo(path).canonicalFilePath(); + + if (!m_dirWatcher->contains(resolvedPath)) { + m_dirWatcher->addDir(resolvedPath); + m_watchedDirs.insert(resolvedPath); } if (!m_queue.isEmpty()) { |
