Merge pull request #2162 from ckamm/error-missing-exclude

Don't do a broken sync when the system exclude file is missing
This commit is contained in:
ckamm 2014-09-04 14:14:07 +02:00
commit 3a59dd24f3
4 changed files with 28 additions and 6 deletions

View file

@ -161,4 +161,5 @@ if(BUILD_OWNCLOUD_OSX_BUNDLE)
configure_file(sync-exclude.lst ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
else()
install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
endif()

View file

@ -533,20 +533,27 @@ void Folder::wipe()
}
}
void Folder::setIgnoredFiles()
bool Folder::setIgnoredFiles()
{
bool ok = false;
MirallConfigFile cfgFile;
csync_clear_exclude_list( _csync_ctx );
QString excludeList = cfgFile.excludeFile( MirallConfigFile::SystemScope );
if( !excludeList.isEmpty() ) {
qDebug() << "==== added system ignore list to csync:" << excludeList.toUtf8();
csync_add_exclude_list( _csync_ctx, excludeList.toUtf8() );
if (csync_add_exclude_list( _csync_ctx, excludeList.toUtf8() ) == 0) {
ok = true;
}
}
excludeList = cfgFile.excludeFile( MirallConfigFile::UserScope );
if( !excludeList.isEmpty() ) {
qDebug() << "==== added user defined ignore list to csync:" << excludeList.toUtf8();
csync_add_exclude_list( _csync_ctx, excludeList.toUtf8() );
// reading the user exclude file is optional
}
return ok;
}
void Folder::setProxyDirty(bool value)
@ -569,7 +576,7 @@ void Folder::startSync(const QStringList &pathList)
if (!_csync_ctx) {
qDebug() << Q_FUNC_INFO << "init failed.";
// the error should already be set
QMetaObject::invokeMethod(this, "slotCSyncFinished", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "slotSyncFinished", Qt::QueuedConnection);
return;
}
_clientProxy.setCSyncProxy(AccountManager::instance()->account()->url(), _csync_ctx);
@ -590,9 +597,15 @@ void Folder::startSync(const QStringList &pathList)
_syncResult.setStatus( SyncResult::SyncPrepare );
emit syncStateChange();
qDebug() << "*** Start syncing";
setIgnoredFiles();
if (! setIgnoredFiles())
{
slotSyncError(tr("Could not read system exclude file"));
QMetaObject::invokeMethod(this, "slotSyncFinished", Qt::QueuedConnection);
return;
}
_engine.reset(new SyncEngine( _csync_ctx, path(), remoteUrl().path(), _remotePath, &_journal));
qRegisterMetaType<SyncFileItemVector>("SyncFileItemVector");

View file

@ -178,7 +178,7 @@ private slots:
private:
bool init();
void setIgnoredFiles();
bool setIgnoredFiles();
void bubbleUpSyncResult();

View file

@ -233,6 +233,14 @@ QString MirallConfigFile::excludeFile(Scope scope) const
#endif
#ifdef Q_OS_UNIX
fi.setFile( QString( SYSCONFDIR "/%1").arg(Theme::instance()->appName()), exclFile );
if ( ! fi.exists() ) {
// Prefer to return the preferred path! Only use the fallback location
// if the other path does not exist and the fallback is valid.
QFileInfo nextToBinary( QCoreApplication::applicationDirPath(), exclFile );
if (nextToBinary.exists()) {
fi = nextToBinary;
}
}
#endif
#ifdef Q_OS_MAC
// exec path is inside the bundle