From 968fcb988cba674efc7ad3961a2eb61ec07f88a9 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 19 Aug 2023 19:16:16 +0200 Subject: [PATCH] Fix finding Syncthing dir by path on Windows The path needs to be normalized so inconsistent uses of `/` and `\` are not a problem. --- syncthingconnector/syncthingconnection.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/syncthingconnector/syncthingconnection.cpp b/syncthingconnector/syncthingconnection.cpp index 6922615..36d4862 100644 --- a/syncthingconnector/syncthingconnection.cpp +++ b/syncthingconnector/syncthingconnection.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -579,12 +580,14 @@ SyncthingDir *SyncthingConnection::findDirInfo(QLatin1String key, const QJsonObj SyncthingDir *SyncthingConnection::findDirInfoByPath(const QString &path, QString &relativePath, int &row) { row = 0; + const auto cleanPath = QDir::cleanPath(path); for (SyncthingDir &dir : m_dirs) { - if (path == dir.pathWithoutTrailingSlash()) { + const auto dirCleanPath = QDir::cleanPath(dir.path); + if (cleanPath == dirCleanPath) { relativePath.clear(); return &dir; - } else if (path.startsWith(dir.path)) { - relativePath = path.mid(dir.path.size()); + } else if (cleanPath.startsWith(dirCleanPath)) { + relativePath = cleanPath.mid(dirCleanPath.size()); return &dir; } ++row;