Skip to content

Commit ce7b856

Browse files
committed
Adapt file browser to API change in Syncthing v1.29.0
This API change is probably unintended but for the time being it is a good idea to workaround it.
1 parent 7ace620 commit ce7b856

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

syncthingconnector/syncthingconnection_requests.cpp

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "./syncthingconnection.h"
22
#include "./utils.h"
3+
#include <qjsonvalue.h>
34

45
#if defined(LIB_SYNCTHING_CONNECTOR_CONNECTION_MOCKED) || defined(LIB_SYNCTHING_CONNECTOR_MOCKED)
56
#include "./syncthingconnectionmockhelpers.h"
@@ -1743,7 +1744,7 @@ static void readSyncthingItems(const QJsonArray &array, std::vector<std::unique_
17431744
continue;
17441745
}
17451746
const auto jsonItemObj = jsonItem.toObject();
1746-
const auto type = jsonItemObj.value(QLatin1String("type")).toString();
1747+
const auto typeValue = jsonItemObj.value(QLatin1String("type"));
17471748
const auto index = into.size();
17481749
const auto children = jsonItemObj.value(QLatin1String("children"));
17491750
auto &item = into.emplace_back(std::make_unique<SyncthingItem>());
@@ -1759,12 +1760,27 @@ static void readSyncthingItems(const QJsonArray &array, std::vector<std::unique_
17591760
);
17601761
item->index = index;
17611762
item->level = level;
1762-
if (type == QLatin1String("FILE_INFO_TYPE_FILE")) {
1763+
switch (typeValue.toInt(-1)) {
1764+
case 0:
17631765
item->type = SyncthingItemType::File;
1764-
} else if (type == QLatin1String("FILE_INFO_TYPE_DIRECTORY")) {
1766+
break;
1767+
case 1:
17651768
item->type = SyncthingItemType::Directory;
1766-
} else if (type == QLatin1String("FILE_INFO_TYPE_SYMLINK")) {
1769+
break;
1770+
case 2:
1771+
case 3:
1772+
case 4:
17671773
item->type = SyncthingItemType::Symlink;
1774+
break;
1775+
default:
1776+
const auto type = typeValue.toString();
1777+
if (type == QLatin1String("FILE_INFO_TYPE_FILE")) {
1778+
item->type = SyncthingItemType::File;
1779+
} else if (type == QLatin1String("FILE_INFO_TYPE_DIRECTORY")) {
1780+
item->type = SyncthingItemType::Directory;
1781+
} else if (type == QLatin1String("FILE_INFO_TYPE_SYMLINK")) {
1782+
item->type = SyncthingItemType::Symlink;
1783+
}
17681784
}
17691785
readSyncthingItems(children.toArray(), item->children, level + 1, levels);
17701786
item->childrenPopulated = !levels || level < levels;

0 commit comments

Comments
 (0)