Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This should fix issue #1000 #1245

Merged
merged 4 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/gui/folderwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/folderwatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QHash>
#include <QScopedPointer>
#include <QSet>
#include <QDir>

class QTimer;

Expand Down Expand Up @@ -120,6 +121,8 @@ protected slots:
Folder *_folder;
bool _isReliable = true;

void appendSubPaths(QDir dir, QStringList& subPaths);

friend class FolderWatcherPrivate;
};
}
Expand Down
11 changes: 11 additions & 0 deletions test/testfolderwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down