Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-05-25 12:12:24 +0300
committerHannah von Reth <vonreth@kde.org>2021-06-15 14:18:34 +0300
commited3969dce7e23875a5c296f98ef10b1f41841673 (patch)
tree4e32087fe691fef0b468032e2a69222eda36c61a /src
parent66ee75ed1285d2f5dc8a1a44ff76397811396b01 (diff)
Fix exclude filtering in selective sync dialog
Fixes: #8648
Diffstat (limited to 'src')
-rw-r--r--src/csync/csync_exclude.cpp19
-rw-r--r--src/csync/csync_exclude.h9
-rw-r--r--src/gui/selectivesyncdialog.cpp28
3 files changed, 30 insertions, 26 deletions
diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp
index c5c7bbccf..6fbfee3f9 100644
--- a/src/csync/csync_exclude.cpp
+++ b/src/csync/csync_exclude.cpp
@@ -319,15 +319,16 @@ bool ExcludedFiles::isExcluded(
const QString &basePath,
bool excludeHidden) const
{
- const QFileInfo fileInfo(filePath);
- if (!fileInfo.exists(filePath)) {
- return true;
- }
if (!filePath.startsWith(basePath, Utility::fsCasePreserving() ? Qt::CaseInsensitive : Qt::CaseSensitive)) {
// Mark paths we're not responsible for as excluded...
return true;
}
+ const QFileInfo fileInfo(filePath);
+ if (!fileInfo.exists(filePath)) {
+ return true;
+ }
+
if (excludeHidden) {
QFileInfo fi = fileInfo;
// Check all path subcomponents, but to *not* check the base path:
@@ -341,11 +342,19 @@ bool ExcludedFiles::isExcluded(
fi = {fi.absolutePath()};
}
}
-
ItemType type = ItemTypeFile;
if (fileInfo.isDir()) {
type = ItemTypeDirectory;
}
+ return isExcludedRemote(filePath, basePath, type);
+}
+
+bool ExcludedFiles::isExcludedRemote(const QString &filePath, const QString &basePath, ItemType type) const
+{
+ if (!filePath.startsWith(basePath, Utility::fsCasePreserving() ? Qt::CaseInsensitive : Qt::CaseSensitive)) {
+ // Mark paths we're not responsible for as excluded...
+ return true;
+ }
auto relativePath = filePath.midRef(basePath.size());
if (relativePath.endsWith(QLatin1Char('/'))) {
diff --git a/src/csync/csync_exclude.h b/src/csync/csync_exclude.h
index f6abaa474..d4c8a5052 100644
--- a/src/csync/csync_exclude.h
+++ b/src/csync/csync_exclude.h
@@ -98,6 +98,15 @@ public:
bool excludeHidden) const;
/**
+ * Checks whether a remote file or directory should be excluded.
+ *
+ * @param filePath the absolute path to the file
+ * @param basePath folder path from which to apply exclude rules, ends with a /
+ */
+ bool isExcludedRemote(const QString &filePath,
+ const QString &basePath, ItemType type = ItemTypeFile) const;
+
+ /**
* Adds an exclude pattern.
*
* Primarily used in tests. Patterns added this way are preserved when
diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp
index 3d6052614..1a2920f19 100644
--- a/src/gui/selectivesyncdialog.cpp
+++ b/src/gui/selectivesyncdialog.cpp
@@ -184,27 +184,17 @@ void SelectiveSyncWidget::recursiveInsert(QTreeWidgetItem *parent, QStringList p
void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
{
auto job = qobject_cast<LsColJob *>(sender());
- QScopedValueRollback<bool> isInserting(_inserting);
- _inserting = true;
+ QScopedValueRollback<bool> isInserting(_inserting, true);
SelectiveSyncTreeViewItem *root = static_cast<SelectiveSyncTreeViewItem *>(_folderTree->topLevelItem(0));
- QUrl url = _account->davUrl();
- QString pathToRemove = url.path();
- if (!pathToRemove.endsWith('/')) {
- pathToRemove.append('/');
- }
- pathToRemove.append(_folderPath);
- if (!_folderPath.isEmpty())
- pathToRemove.append('/');
+ const QString pathToRemove = Utility::concatUrlPath(_account->davUrl(), _folderPath).path();
// Check for excludes.
- QMutableListIterator<QString> it(list);
- while (it.hasNext()) {
- it.next();
- if (_excludedFiles.isExcluded(it.value(), pathToRemove, FolderMan::instance()->ignoreHiddenFiles()))
- it.remove();
- }
+ list.erase(std::remove_if(list.begin(), list.end(), [&pathToRemove, this](const QString &it) {
+ return _excludedFiles.isExcludedRemote(it, pathToRemove, ItemTypeDirectory);
+ }),
+ list.end());
// Since / cannot be in the blacklist, expand it to the actual
// list of top-level folders as soon as possible.
@@ -282,11 +272,7 @@ void SelectiveSyncWidget::slotItemExpanded(QTreeWidgetItem *item)
QString dir = item->data(0, Qt::UserRole).toString();
if (dir.isEmpty())
return;
- QString prefix;
- if (!_folderPath.isEmpty()) {
- prefix = _folderPath + QLatin1Char('/');
- }
- LsColJob *job = new LsColJob(_account, prefix + dir, this);
+ LsColJob *job = new LsColJob(_account, _folderPath + dir, this);
job->setProperties(QList<QByteArray>() << "resourcetype"
<< "http://owncloud.org/ns:size");
connect(job, &LsColJob::directoryListingSubfolders,