Fix finding Syncthing dir by path on Windows
The path needs to be normalized so inconsistent uses of `/` and `\` are not a problem.
This commit is contained in:
parent
652497d06e
commit
968fcb988c
|
@ -13,6 +13,7 @@
|
||||||
#include <c++utilities/io/ansiescapecodes.h>
|
#include <c++utilities/io/ansiescapecodes.h>
|
||||||
|
|
||||||
#include <QAuthenticator>
|
#include <QAuthenticator>
|
||||||
|
#include <QDir>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
@ -579,12 +580,14 @@ SyncthingDir *SyncthingConnection::findDirInfo(QLatin1String key, const QJsonObj
|
||||||
SyncthingDir *SyncthingConnection::findDirInfoByPath(const QString &path, QString &relativePath, int &row)
|
SyncthingDir *SyncthingConnection::findDirInfoByPath(const QString &path, QString &relativePath, int &row)
|
||||||
{
|
{
|
||||||
row = 0;
|
row = 0;
|
||||||
|
const auto cleanPath = QDir::cleanPath(path);
|
||||||
for (SyncthingDir &dir : m_dirs) {
|
for (SyncthingDir &dir : m_dirs) {
|
||||||
if (path == dir.pathWithoutTrailingSlash()) {
|
const auto dirCleanPath = QDir::cleanPath(dir.path);
|
||||||
|
if (cleanPath == dirCleanPath) {
|
||||||
relativePath.clear();
|
relativePath.clear();
|
||||||
return &dir;
|
return &dir;
|
||||||
} else if (path.startsWith(dir.path)) {
|
} else if (cleanPath.startsWith(dirCleanPath)) {
|
||||||
relativePath = path.mid(dir.path.size());
|
relativePath = cleanPath.mid(dirCleanPath.size());
|
||||||
return &dir;
|
return &dir;
|
||||||
}
|
}
|
||||||
++row;
|
++row;
|
||||||
|
|
Loading…
Reference in New Issue