Exclusion: Fix confusion with relative and absolute paths

This commit is contained in:
Christian Kamm 2015-10-13 12:53:38 +02:00
parent 7fe03c715d
commit 51a2e6c580
6 changed files with 19 additions and 9 deletions

View file

@ -707,7 +707,7 @@ void Folder::removeFromSettings() const
settings->remove(_definition.alias);
}
bool Folder::isFileExcluded(const QString& fullPath) const
bool Folder::isFileExcludedAbsolute(const QString& fullPath) const
{
QString myFullPath = fullPath;
if (myFullPath.endsWith(QLatin1Char('/'))) {
@ -724,6 +724,11 @@ bool Folder::isFileExcluded(const QString& fullPath) const
return excl != CSYNC_NOT_EXCLUDED;
}
bool Folder::isFileExcludedRelative(const QString& relativePath) const
{
return isFileExcludedAbsolute(path() + relativePath);
}
void Folder::watcherSlot(QString fn)
{
// FIXME: On OS X we could not do this "if" since on OS X the file watcher ignores events for ourselves

View file

@ -200,7 +200,12 @@ public:
/**
* Returns whether a file inside this folder should be excluded.
*/
bool isFileExcluded(const QString& fullPath) const;
bool isFileExcludedAbsolute(const QString& fullPath) const;
/**
* Returns whether a file inside this folder should be excluded.
*/
bool isFileExcludedRelative(const QString& relativePath) const;
signals:
void syncStateChange();

View file

@ -514,10 +514,9 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
QMutableListIterator<QString> it(list);
while (it.hasNext()) {
it.next();
if (parentInfo->_folder->isFileExcluded(it.value())) {
it.value().remove(pathToRemove);
if (parentInfo->_folder->isFileExcludedRelative(it.value())) {
it.remove();
} else {
it.value().remove(pathToRemove);
}
}

View file

@ -55,7 +55,7 @@ bool FolderWatcher::pathIsIgnored( const QString& path )
if( !_folder ) return false;
#ifndef OWNCLOUD_TEST
if (_folder->isFileExcluded(path)) {
if (_folder->isFileExcludedAbsolute(path)) {
qDebug() << "* Ignoring file" << path;
return true;
}

View file

@ -185,7 +185,9 @@ void SelectiveSyncTreeView::slotUpdateDirectories(QStringList list)
QMutableListIterator<QString> it(list);
while (it.hasNext()) {
it.next();
if (f.isFileExcluded(it.value())) {
QString path = it.value();
path.remove(pathToRemove);
if (f.isFileExcludedRelative(path)) {
it.remove();
}
}
@ -195,7 +197,6 @@ void SelectiveSyncTreeView::slotUpdateDirectories(QStringList list)
if (_oldBlackList == QStringList("/")) {
_oldBlackList.clear();
foreach (QString path, list) {
path.remove(pathToRemove);
if (path.isEmpty()) {
continue;
}

View file

@ -540,7 +540,7 @@ SyncFileStatus SocketApi::fileStatus(Folder *folder, const QString& systemFileNa
}
// Is it excluded?
if( folder->isFileExcluded(file) ) {
if( folder->isFileExcludedAbsolute(file) ) {
return SyncFileStatus(SyncFileStatus::STATUS_IGNORE);
}