mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Let folderwatcher use the exclude list file.
simplified naming in mirallconfigfile class.
This commit is contained in:
parent
47f5c51a87
commit
84ffebe26c
@ -151,10 +151,11 @@ void CSyncThread::run()
|
||||
csync_set_auth_callback( csync, getauth );
|
||||
csync_enable_conflictcopys(csync);
|
||||
|
||||
|
||||
MirallConfigFile cfg;
|
||||
QString excludeList = cfg.configPath() + "exclude.lst";
|
||||
QFileInfo fi( excludeList );
|
||||
if( fi.isReadable() ) {
|
||||
QString excludeList = cfg.excludeFile();
|
||||
|
||||
if( !excludeList.isEmpty() ) {
|
||||
qDebug() << "==== added CSync exclude List: " << excludeList.toAscii();
|
||||
csync_add_exclude_list( csync, excludeList.toAscii() );
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include "mirall/folder.h"
|
||||
#include "mirall/folderwatcher.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
|
||||
#define DEFAULT_POLL_INTERVAL_SEC 15000
|
||||
|
||||
@ -46,6 +47,11 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP
|
||||
|
||||
#ifdef USE_WATCHER
|
||||
_watcher = new Mirall::FolderWatcher(path, this);
|
||||
|
||||
MirallConfigFile cfg;
|
||||
|
||||
_watcher->setIgnoreListFile( cfg.excludeFile() );
|
||||
|
||||
QObject::connect(_watcher, SIGNAL(folderChanged(const QStringList &)),
|
||||
SLOT(slotChanged(const QStringList &)));
|
||||
#endif
|
||||
|
||||
@ -53,11 +53,6 @@ FolderWatcher::FolderWatcher(const QString &root, QObject *parent)
|
||||
_lastMask(0),
|
||||
_initialSyncDone(false)
|
||||
{
|
||||
// this is not the best place for this
|
||||
addIgnore(".unison*");
|
||||
addIgnore("*csync_timediff.ctmp*");
|
||||
addIgnore(".*.sw?"); // vi swap files
|
||||
addIgnore(".*.*.sw?");
|
||||
#ifdef USE_WATCHER
|
||||
_processTimer->setSingleShot(true);
|
||||
QObject::connect(_processTimer, SIGNAL(timeout()), this, SLOT(slotProcessTimerTimeout()));
|
||||
@ -82,8 +77,25 @@ QString FolderWatcher::root() const
|
||||
return _root;
|
||||
}
|
||||
|
||||
void FolderWatcher::setIgnoreListFile( const QString& file )
|
||||
{
|
||||
if( file.isEmpty() ) return;
|
||||
|
||||
QFile infile( file );
|
||||
if (!infile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return;
|
||||
|
||||
while (!infile.atEnd()) {
|
||||
QString line = QString::fromLocal8Bit( infile.readLine() ).trimmed();
|
||||
if( !line.startsWith( '#' )) {
|
||||
addIgnore(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FolderWatcher::addIgnore(const QString &pattern)
|
||||
{
|
||||
if( pattern.isEmpty() ) return;
|
||||
_ignores.append(pattern);
|
||||
}
|
||||
|
||||
@ -208,10 +220,10 @@ void FolderWatcher::slotINotifyEvent(int mask, int cookie, const QString &path)
|
||||
}
|
||||
else if (mask & IN_DELETE) {
|
||||
//qDebug() << cookie << " DELETE: " << path;
|
||||
if (_inotify->directories().contains(path) &&
|
||||
QFileInfo(path).isDir());
|
||||
if ( QFileInfo(path).isDir() && _inotify->directories().contains(path) ) {
|
||||
qDebug() << "(-) Watcher:" << path;
|
||||
_inotify->removePath(path);
|
||||
_inotify->removePath(path);
|
||||
}
|
||||
}
|
||||
else if (mask & IN_CLOSE_WRITE) {
|
||||
//qDebug() << cookie << " WRITABLE CLOSED: " << path;
|
||||
@ -228,12 +240,12 @@ void FolderWatcher::slotINotifyEvent(int mask, int cookie, const QString &path)
|
||||
regexp.setPatternSyntax(QRegExp::Wildcard);
|
||||
|
||||
if (regexp.exactMatch(path)) {
|
||||
qDebug() << "* Discarded " << path;
|
||||
qDebug() << "* Discarded by ignore pattern: " << path;
|
||||
return;
|
||||
}
|
||||
QFileInfo fInfo(path);
|
||||
if( regexp.exactMatch(fInfo.fileName())) {
|
||||
qDebug() << "* Discarded " << path;
|
||||
qDebug() << "* Discarded by ignore pattern:" << path;
|
||||
return;
|
||||
}
|
||||
if( fInfo.isHidden() ) {
|
||||
@ -246,10 +258,6 @@ void FolderWatcher::slotINotifyEvent(int mask, int cookie, const QString &path)
|
||||
_pendingPathes[path] = 0;
|
||||
}
|
||||
_pendingPathes[path] = _pendingPathes[path]+mask;
|
||||
#if 0
|
||||
_pendingPaths[path]
|
||||
_pendingPaths.append(path);
|
||||
#endif
|
||||
#endif
|
||||
setProcessTimer();
|
||||
}
|
||||
|
||||
@ -60,6 +60,11 @@ public:
|
||||
*/
|
||||
QString root() const;
|
||||
|
||||
/**
|
||||
* Set a file name to load a file with ignore patterns.
|
||||
*/
|
||||
void setIgnoreListFile( const QString& );
|
||||
|
||||
/**
|
||||
* Add an ignore pattern that will not be
|
||||
* notified
|
||||
|
||||
@ -31,7 +31,18 @@ QString MirallConfigFile::configPath() const
|
||||
return dir;
|
||||
}
|
||||
|
||||
QString MirallConfigFile::mirallConfigFile() const
|
||||
QString MirallConfigFile::excludeFile() const
|
||||
{
|
||||
QString dir = configPath();
|
||||
dir += "exclude.lst";
|
||||
QFileInfo fi( dir );
|
||||
if( fi.isReadable() ) {
|
||||
return dir;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString MirallConfigFile::configFile() const
|
||||
{
|
||||
#ifdef OWNCLOUD_CLIENT
|
||||
ownCloudTheme theme;
|
||||
@ -47,7 +58,7 @@ QString MirallConfigFile::mirallConfigFile() const
|
||||
|
||||
bool MirallConfigFile::exists()
|
||||
{
|
||||
QFile file( mirallConfigFile() );
|
||||
QFile file( configFile() );
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
@ -61,7 +72,7 @@ bool MirallConfigFile::connectionExists( const QString& conn )
|
||||
QString con = conn;
|
||||
if( conn.isEmpty() ) con = defaultConnection();
|
||||
|
||||
QSettings settings( mirallConfigFile(), QSettings::IniFormat);
|
||||
QSettings settings( configFile(), QSettings::IniFormat);
|
||||
|
||||
return settings.contains( QString("%1/url").arg( conn ) );
|
||||
}
|
||||
@ -72,7 +83,7 @@ void MirallConfigFile::writeOwncloudConfig( const QString& connection,
|
||||
const QString& user,
|
||||
const QString& passwd )
|
||||
{
|
||||
const QString file = mirallConfigFile();
|
||||
const QString file = configFile();
|
||||
qDebug() << "*** writing mirall config to " << file;
|
||||
|
||||
QSettings settings( file, QSettings::IniFormat);
|
||||
@ -101,7 +112,7 @@ void MirallConfigFile::removeConnection( const QString& connection )
|
||||
qDebug() << " removing the config file for connection " << con;
|
||||
|
||||
// Currently its just removing the entire config file
|
||||
QSettings settings( mirallConfigFile(), QSettings::IniFormat);
|
||||
QSettings settings( configFile(), QSettings::IniFormat);
|
||||
settings.beginGroup( con );
|
||||
settings.remove(""); // removes all content from the group
|
||||
settings.sync();
|
||||
@ -118,7 +129,7 @@ QString MirallConfigFile::ownCloudUrl( const QString& connection, bool webdav )
|
||||
QString con( connection );
|
||||
if( connection.isEmpty() ) con = defaultConnection();
|
||||
|
||||
QSettings settings( mirallConfigFile(), QSettings::IniFormat );
|
||||
QSettings settings( configFile(), QSettings::IniFormat );
|
||||
settings.beginGroup( con );
|
||||
|
||||
QString url = settings.value( "url" ).toString();
|
||||
@ -137,7 +148,7 @@ QString MirallConfigFile::ownCloudUser( const QString& connection ) const
|
||||
QString con( connection );
|
||||
if( connection.isEmpty() ) con = defaultConnection();
|
||||
|
||||
QSettings settings( mirallConfigFile(), QSettings::IniFormat );
|
||||
QSettings settings( configFile(), QSettings::IniFormat );
|
||||
settings.beginGroup( con );
|
||||
|
||||
QString user = settings.value( "user" ).toString();
|
||||
@ -151,7 +162,7 @@ QString MirallConfigFile::ownCloudPasswd( const QString& connection ) const
|
||||
QString con( connection );
|
||||
if( connection.isEmpty() ) con = defaultConnection();
|
||||
|
||||
QSettings settings( mirallConfigFile(), QSettings::IniFormat );
|
||||
QSettings settings( configFile(), QSettings::IniFormat );
|
||||
settings.beginGroup( con );
|
||||
|
||||
QString pwd = settings.value( "password" ).toString();
|
||||
|
||||
@ -24,7 +24,9 @@ public:
|
||||
MirallConfigFile();
|
||||
|
||||
QString configPath() const;
|
||||
QString mirallConfigFile() const;
|
||||
QString configFile() const;
|
||||
QString excludeFile() const;
|
||||
|
||||
bool exists();
|
||||
|
||||
bool connectionExists( const QString& = QString() );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user