Merge pull request #1245 from joshua-sterner/master

This should fix issue #1000.
This commit is contained in:
Camila Ayres 2019-05-10 17:04:40 +02:00 committed by GitHub
commit 419b8a3ff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View File

@ -75,9 +75,27 @@ bool FolderWatcher::isReliable() const
return _isReliable;
}
void FolderWatcher::appendSubPaths(QDir dir, QStringList& subPaths) {
QStringList newSubPaths = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files);
for (int i = 0; i < newSubPaths.size(); i++) {
QString path = dir.path() + "/" + newSubPaths[i];
QFileInfo fileInfo(path);
subPaths.append(path);
if (fileInfo.isDir()) {
QDir dir(path);
appendSubPaths(dir, subPaths);
}
}
}
void FolderWatcher::changeDetected(const QString &path)
{
QFileInfo fileInfo(path);
QStringList paths(path);
if (fileInfo.isDir()) {
QDir dir(path);
appendSubPaths(dir, paths);
}
changeDetected(paths);
}

View File

@ -26,6 +26,7 @@
#include <QHash>
#include <QScopedPointer>
#include <QSet>
#include <QDir>
class QTimer;
@ -120,6 +121,8 @@ private:
Folder *_folder;
bool _isReliable = true;
void appendSubPaths(QDir dir, QStringList& subPaths);
friend class FolderWatcherPrivate;
};
}

View File

@ -140,6 +140,17 @@ private slots:
QVERIFY(waitForPathChanged(file));
}
void testMove3LevelDirWithFile() {
QString file(_rootPath + "/a0/b/c/empty.txt");
mkdir(_rootPath + "/a0");
mkdir(_rootPath + "/a0/b");
mkdir(_rootPath + "/a0/b/c");
touch(file);
mv(_rootPath + "/a0 ", _rootPath + "/a");
QVERIFY(waitForPathChanged(_rootPath + "/a/b/c/empty.txt"));
}
void testCreateADir() {
QString file(_rootPath+"/a1/b1/new_dir");
mkdir(file);