Comparar commits

..

1 Commits

Autor SHA1 Mensagem Data
Olivier Goffart 621f984dc3 SyncEngine: Fix renaming a folder should keep the selective sync state
Issue #5224

Two problems:

 - In the discovery phase, we need to check the selective sync entries of
   the source path in case of renames.

 - When the rename is done, we need to actually update the black list in the
   database.
2016-10-11 14:33:44 +02:00
8 arquivos alterados com 3025 adições e 4215 exclusões
+2678 -3731
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+267 -421
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+2 -7
Ver Arquivo
@@ -336,13 +336,8 @@ void Application::slotownCloudWizardDone( int res )
_checkConnectionTimer.start();
slotCheckConnection();
// If one account is configured: enable autostart
bool shouldSetAutoStart = (accountMan->accounts().size() == 1);
#ifdef Q_OS_MAC
// Don't auto start when not being 'installed'
shouldSetAutoStart = shouldSetAutoStart
&& QCoreApplication::applicationDirPath().startsWith("/Applications/");
#endif
// The very first time an account is configured: enabled autostart
// TODO: Doing this every time the account wizard finishes will annoy users.
Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), true);
}
}
+1 -1
Ver Arquivo
@@ -188,7 +188,7 @@ QString Folder::shortGuiLocalPath() const
}
bool Folder::ignoreHiddenFiles() const
bool Folder::ignoreHiddenFiles()
{
bool re(_definition.ignoreHiddenFiles);
return re;
+1 -1
Ver Arquivo
@@ -167,7 +167,7 @@ public:
* Ignore syncing of hidden files or not. This is defined in the
* folder definition
*/
bool ignoreHiddenFiles() const;
bool ignoreHiddenFiles();
void setIgnoreHiddenFiles(bool ignore);
// Used by the Socket API
+48 -30
Ver Arquivo
@@ -23,7 +23,6 @@
#include <QStringList>
#include <QObject>
#include <QVarLengthArray>
#include <syncengine.h>
namespace OCC {
@@ -49,6 +48,31 @@ FolderWatcherPrivate::~FolderWatcherPrivate()
}
// attention: result list passed by reference!
bool FolderWatcherPrivate::findFoldersBelow( const QDir& dir, QStringList& fullList )
{
bool ok = true;
if( !(dir.exists() && dir.isReadable()) ) {
qDebug() << "Non existing path coming in: " << dir.absolutePath();
ok = false;
} else {
QStringList nameFilter;
nameFilter << QLatin1String("*");
QDir::Filters filter = QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Hidden;
const QStringList pathes = dir.entryList(nameFilter, filter);
QStringList::const_iterator constIterator;
for (constIterator = pathes.constBegin(); constIterator != pathes.constEnd();
++constIterator) {
const QString fullPath(dir.path()+QLatin1String("/")+(*constIterator));
fullList.append(fullPath);
ok = findFoldersBelow(QDir(fullPath), fullList);
}
}
return ok;
}
void FolderWatcherPrivate::inotifyRegisterPath(const QString& path)
{
if( !path.isEmpty()) {
@@ -64,46 +88,40 @@ void FolderWatcherPrivate::inotifyRegisterPath(const QString& path)
void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path)
{
int subdirs = 0;
qDebug() << "(+) Watcher:" << path;
QDir inPath(path);
inotifyRegisterPath(inPath.absolutePath());
const QStringList watchedFolders = _watches.values();
int subdirs = addFolderRecursiveHelper(path, watchedFolders.toSet());
if (subdirs >0) {
qDebug() << " `-> and" << subdirs << "subdirectories";
QStringList allSubfolders;
if( !findFoldersBelow(QDir(path), allSubfolders)) {
qDebug() << "Could not traverse all sub folders";
}
}
int FolderWatcherPrivate::addFolderRecursiveHelper(const QString &path, const QSet<QString> &watchedFolders)
{
QDir dir(path);
if( !(dir.exists() && dir.isReadable()) ) {
qDebug() << "Non existing path coming in: " << dir.absolutePath();
return 0;
}
int subdirs = 1;
inotifyRegisterPath(dir.absolutePath());
QDir::Filters filter = QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Hidden;
const QStringList pathes = dir.entryList(filter);
for (auto constIterator = pathes.constBegin(); constIterator != pathes.constEnd(); ++constIterator) {
const QString subfolder = path + QLatin1String("/") + (*constIterator);
QDir folder(subfolder);
if (folder.exists() && !watchedFolders.contains(subfolder)) {
#ifndef OWNCLOUD_TEST // InotifyWatcherTest is not interested in ignored files and does not link against the folder
if( _parent->_folder->syncEngine().excludedFiles().isExcluded(
subfolder, path, _parent->_folder->ignoreHiddenFiles())) {
// qDebug() << "currently watching " << watchedFolders;
QStringListIterator subfoldersIt(allSubfolders);
while (subfoldersIt.hasNext()) {
QString subfolder = subfoldersIt.next();
// qDebug() << " (**) subfolder: " << subfolder;
QDir folder (subfolder);
if (folder.exists() && !watchedFolders.contains(folder.absolutePath())) {
subdirs++;
if( _parent->pathIsIgnored(subfolder) ) {
qDebug() << "* Not adding" << folder.path();
continue;
}
#endif
subdirs += addFolderRecursiveHelper(subfolder, watchedFolders);
inotifyRegisterPath(folder.absolutePath());
} else {
qDebug() << " `-> discarded:" << folder.path();
}
}
return subdirs;
}
if (subdirs >0) {
qDebug() << " `-> and" << subdirs << "subdirectories";
}
}
void FolderWatcherPrivate::slotReceivedNotification(int fd)
{
+3 -1
Ver Arquivo
@@ -33,6 +33,7 @@ class FolderWatcherPrivate : public QObject
{
Q_OBJECT
public:
FolderWatcherPrivate() { }
FolderWatcherPrivate(FolderWatcher *p, const QString &path);
~FolderWatcherPrivate();
@@ -44,9 +45,10 @@ protected slots:
void slotAddFolderRecursive(const QString &path);
protected:
int addFolderRecursiveHelper(const QString &path, const QSet<QString> &watchedFolders);
bool findFoldersBelow( const QDir& dir, QStringList& fullList );
void inotifyRegisterPath(const QString& path);
private:
FolderWatcher *_parent;
QString _folder;
+25 -23
Ver Arquivo
@@ -11,23 +11,18 @@
using namespace OCC;
struct FriendlyFolderWatcherPrivate : FolderWatcherPrivate
{
using FolderWatcherPrivate::FolderWatcherPrivate;
friend class TestInotifyWatcher;
};
class TestInotifyWatcher : public QObject
class TestInotifyWatcher: public FolderWatcherPrivate
{
Q_OBJECT
private slots:
// Test the recursive path listing function lists everything
void testAddFolderRecursiveHelper() {
QTemporaryDir tmpDir;
QString _root = tmpDir.path();
private:
QString _root;
private slots:
void initTestCase() {
qsrand(QTime::currentTime().msec());
_root = QDir::tempPath() + "/" + "test_" + QString::number(qrand());
qDebug() << "creating test directory tree in " << _root;
QDir rootDir(_root);
@@ -37,13 +32,13 @@ private slots:
rootDir.mkpath(_root + "/a1/b3/c3");
rootDir.mkpath(_root + "/a2/b3/c3");
FriendlyFolderWatcherPrivate watcher(0, _root);
QVERIFY(watcher._fd >= 0);
QCoreApplication::processEvents(); // Let the slotAddFolderRecursive slot run;
QStringList dirs = watcher._watches.values();
}
QVERIFY( dirs.indexOf(_root)>-1);
// Test the recursive path listing function findFoldersBelow
void testDirsBelowPath() {
QStringList dirs;
bool ok = findFoldersBelow(QDir(_root), dirs);
QVERIFY( dirs.indexOf(_root + "/a1")>-1);
QVERIFY( dirs.indexOf(_root + "/a1/b1")>-1);
QVERIFY( dirs.indexOf(_root + "/a1/b1/c1")>-1);
@@ -58,13 +53,20 @@ private slots:
QVERIFY( dirs.indexOf(_root + "/a1/b3")>-1);
QVERIFY( dirs.indexOf(_root + "/a1/b3/c3")>-1);
QVERIFY( dirs.contains(_root + "/a2"));
QVERIFY( dirs.contains(_root + "/a2/b3"));
QVERIFY( dirs.contains(_root + "/a2/b3/c3"));
QVERIFY( dirs.indexOf(_root + "/a2"));
QVERIFY( dirs.indexOf(_root + "/a2/b3"));
QVERIFY( dirs.indexOf(_root + "/a2/b3/c3"));
QCOMPARE(dirs.count(), 12);
QVERIFY2(dirs.count() == 11, "Directory count wrong.");
QVERIFY2(ok, "findFoldersBelow failed.");
}
void cleanupTestCase() {
if( _root.startsWith(QDir::tempPath() )) {
system( QString("rm -rf %1").arg(_root).toLocal8Bit() );
}
}
};
QTEST_APPLESS_MAIN(TestInotifyWatcher)