Skip to content

Commit 265385d

Browse files
authored
Merge pull request #8921 from nextcloud/bugfix/8915/lscol-root
fix: ignore directory listing entry for the iterated directory
2 parents 4417cf6 + 438b0af commit 265385d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/libsync/account.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,14 @@ void Account::listRemoteFolder(QPromise<OCC::PlaceholderCreateInfo> *promise, co
12131213
promise->finish();
12141214
});
12151215

1216-
auto ignoreFirst = true;
1217-
QObject::connect(listFolderJob, &OCC::LsColJob::directoryListingIterated, this, [&ignoreFirst, promise, path, journalForFolder, this] (const QString &name, const QMap<QString, QString> &properties) {
1218-
if (ignoreFirst) {
1216+
QObject::connect(listFolderJob, &OCC::LsColJob::directoryListingIterated, this, [promise, path, journalForFolder, this](const QString &name, const QMap<QString, QString> &properties) {
1217+
// `name` is e.g. "/remote.php/dav/files/admin" or "/remote.php/dav/files/admin/SomeFolder"; whereas `path` is e.g. "" or "SomeFolder/"
1218+
// in case these two are equal we are currently iterating the entry for the current directory
1219+
const auto serverPath = name.mid(this->davPath().size());
1220+
const auto isRootCollection = serverPath.isEmpty() && path.isEmpty();
1221+
const auto isCurrentCollection = isRootCollection || serverPath == Utility::noTrailingSlashPath(path);
1222+
if (isCurrentCollection) {
12191223
qCDebug(lcAccount()) << "skip first item";
1220-
ignoreFirst = false;
12211224
return;
12221225
}
12231226

0 commit comments

Comments
 (0)