Comparar commits
1 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 621f984dc3 |
externo
+2678
-3731
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
externo
+267
-421
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -336,13 +336,8 @@ void Application::slotownCloudWizardDone( int res )
|
|||||||
_checkConnectionTimer.start();
|
_checkConnectionTimer.start();
|
||||||
slotCheckConnection();
|
slotCheckConnection();
|
||||||
|
|
||||||
// If one account is configured: enable autostart
|
// The very first time an account is configured: enabled autostart
|
||||||
bool shouldSetAutoStart = (accountMan->accounts().size() == 1);
|
// TODO: Doing this every time the account wizard finishes will annoy users.
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
// Don't auto start when not being 'installed'
|
|
||||||
shouldSetAutoStart = shouldSetAutoStart
|
|
||||||
&& QCoreApplication::applicationDirPath().startsWith("/Applications/");
|
|
||||||
#endif
|
|
||||||
Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), true);
|
Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ QString Folder::shortGuiLocalPath() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Folder::ignoreHiddenFiles() const
|
bool Folder::ignoreHiddenFiles()
|
||||||
{
|
{
|
||||||
bool re(_definition.ignoreHiddenFiles);
|
bool re(_definition.ignoreHiddenFiles);
|
||||||
return re;
|
return re;
|
||||||
|
|||||||
+1
-1
@@ -167,7 +167,7 @@ public:
|
|||||||
* Ignore syncing of hidden files or not. This is defined in the
|
* Ignore syncing of hidden files or not. This is defined in the
|
||||||
* folder definition
|
* folder definition
|
||||||
*/
|
*/
|
||||||
bool ignoreHiddenFiles() const;
|
bool ignoreHiddenFiles();
|
||||||
void setIgnoreHiddenFiles(bool ignore);
|
void setIgnoreHiddenFiles(bool ignore);
|
||||||
|
|
||||||
// Used by the Socket API
|
// Used by the Socket API
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVarLengthArray>
|
#include <QVarLengthArray>
|
||||||
#include <syncengine.h>
|
|
||||||
|
|
||||||
namespace OCC {
|
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)
|
void FolderWatcherPrivate::inotifyRegisterPath(const QString& path)
|
||||||
{
|
{
|
||||||
if( !path.isEmpty()) {
|
if( !path.isEmpty()) {
|
||||||
@@ -64,46 +88,40 @@ void FolderWatcherPrivate::inotifyRegisterPath(const QString& path)
|
|||||||
|
|
||||||
void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path)
|
void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path)
|
||||||
{
|
{
|
||||||
|
int subdirs = 0;
|
||||||
qDebug() << "(+) Watcher:" << path;
|
qDebug() << "(+) Watcher:" << path;
|
||||||
|
|
||||||
|
QDir inPath(path);
|
||||||
|
inotifyRegisterPath(inPath.absolutePath());
|
||||||
|
|
||||||
const QStringList watchedFolders = _watches.values();
|
const QStringList watchedFolders = _watches.values();
|
||||||
int subdirs = addFolderRecursiveHelper(path, watchedFolders.toSet());
|
|
||||||
if (subdirs >0) {
|
QStringList allSubfolders;
|
||||||
qDebug() << " `-> and" << subdirs << "subdirectories";
|
if( !findFoldersBelow(QDir(path), allSubfolders)) {
|
||||||
|
qDebug() << "Could not traverse all sub folders";
|
||||||
}
|
}
|
||||||
}
|
// qDebug() << "currently watching " << watchedFolders;
|
||||||
|
QStringListIterator subfoldersIt(allSubfolders);
|
||||||
int FolderWatcherPrivate::addFolderRecursiveHelper(const QString &path, const QSet<QString> &watchedFolders)
|
while (subfoldersIt.hasNext()) {
|
||||||
{
|
QString subfolder = subfoldersIt.next();
|
||||||
QDir dir(path);
|
// qDebug() << " (**) subfolder: " << subfolder;
|
||||||
if( !(dir.exists() && dir.isReadable()) ) {
|
QDir folder (subfolder);
|
||||||
qDebug() << "Non existing path coming in: " << dir.absolutePath();
|
if (folder.exists() && !watchedFolders.contains(folder.absolutePath())) {
|
||||||
return 0;
|
subdirs++;
|
||||||
}
|
if( _parent->pathIsIgnored(subfolder) ) {
|
||||||
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() << "* Not adding" << folder.path();
|
qDebug() << "* Not adding" << folder.path();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
inotifyRegisterPath(folder.absolutePath());
|
||||||
subdirs += addFolderRecursiveHelper(subfolder, watchedFolders);
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << " `-> discarded:" << folder.path();
|
qDebug() << " `-> discarded:" << folder.path();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return subdirs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (subdirs >0) {
|
||||||
|
qDebug() << " `-> and" << subdirs << "subdirectories";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FolderWatcherPrivate::slotReceivedNotification(int fd)
|
void FolderWatcherPrivate::slotReceivedNotification(int fd)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class FolderWatcherPrivate : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
FolderWatcherPrivate() { }
|
||||||
FolderWatcherPrivate(FolderWatcher *p, const QString &path);
|
FolderWatcherPrivate(FolderWatcher *p, const QString &path);
|
||||||
~FolderWatcherPrivate();
|
~FolderWatcherPrivate();
|
||||||
|
|
||||||
@@ -44,9 +45,10 @@ protected slots:
|
|||||||
void slotAddFolderRecursive(const QString &path);
|
void slotAddFolderRecursive(const QString &path);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int addFolderRecursiveHelper(const QString &path, const QSet<QString> &watchedFolders);
|
bool findFoldersBelow( const QDir& dir, QStringList& fullList );
|
||||||
void inotifyRegisterPath(const QString& path);
|
void inotifyRegisterPath(const QString& path);
|
||||||
|
|
||||||
|
private:
|
||||||
FolderWatcher *_parent;
|
FolderWatcher *_parent;
|
||||||
|
|
||||||
QString _folder;
|
QString _folder;
|
||||||
|
|||||||
@@ -11,23 +11,18 @@
|
|||||||
|
|
||||||
using namespace OCC;
|
using namespace OCC;
|
||||||
|
|
||||||
|
class TestInotifyWatcher: public FolderWatcherPrivate
|
||||||
struct FriendlyFolderWatcherPrivate : FolderWatcherPrivate
|
|
||||||
{
|
|
||||||
using FolderWatcherPrivate::FolderWatcherPrivate;
|
|
||||||
friend class TestInotifyWatcher;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class TestInotifyWatcher : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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;
|
qDebug() << "creating test directory tree in " << _root;
|
||||||
QDir rootDir(_root);
|
QDir rootDir(_root);
|
||||||
|
|
||||||
@@ -37,13 +32,13 @@ private slots:
|
|||||||
rootDir.mkpath(_root + "/a1/b3/c3");
|
rootDir.mkpath(_root + "/a1/b3/c3");
|
||||||
rootDir.mkpath(_root + "/a2/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")>-1);
|
||||||
QVERIFY( dirs.indexOf(_root + "/a1/b1")>-1);
|
QVERIFY( dirs.indexOf(_root + "/a1/b1")>-1);
|
||||||
QVERIFY( dirs.indexOf(_root + "/a1/b1/c1")>-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")>-1);
|
||||||
QVERIFY( dirs.indexOf(_root + "/a1/b3/c3")>-1);
|
QVERIFY( dirs.indexOf(_root + "/a1/b3/c3")>-1);
|
||||||
|
|
||||||
QVERIFY( dirs.contains(_root + "/a2"));
|
QVERIFY( dirs.indexOf(_root + "/a2"));
|
||||||
QVERIFY( dirs.contains(_root + "/a2/b3"));
|
QVERIFY( dirs.indexOf(_root + "/a2/b3"));
|
||||||
QVERIFY( dirs.contains(_root + "/a2/b3/c3"));
|
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)
|
QTEST_APPLESS_MAIN(TestInotifyWatcher)
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário