1
1
#include " ./syncthingconnection.h"
2
2
#include " ./utils.h"
3
+ #include < qjsonvalue.h>
3
4
4
5
#if defined(LIB_SYNCTHING_CONNECTOR_CONNECTION_MOCKED) || defined(LIB_SYNCTHING_CONNECTOR_MOCKED)
5
6
#include " ./syncthingconnectionmockhelpers.h"
@@ -1743,7 +1744,7 @@ static void readSyncthingItems(const QJsonArray &array, std::vector<std::unique_
1743
1744
continue ;
1744
1745
}
1745
1746
const auto jsonItemObj = jsonItem.toObject ();
1746
- const auto type = jsonItemObj.value (QLatin1String (" type" )). toString ( );
1747
+ const auto typeValue = jsonItemObj.value (QLatin1String (" type" ));
1747
1748
const auto index = into.size ();
1748
1749
const auto children = jsonItemObj.value (QLatin1String (" children" ));
1749
1750
auto &item = into.emplace_back (std::make_unique<SyncthingItem>());
@@ -1759,12 +1760,27 @@ static void readSyncthingItems(const QJsonArray &array, std::vector<std::unique_
1759
1760
);
1760
1761
item->index = index ;
1761
1762
item->level = level;
1762
- if (type == QLatin1String (" FILE_INFO_TYPE_FILE" )) {
1763
+ switch (typeValue.toInt (-1 )) {
1764
+ case 0 :
1763
1765
item->type = SyncthingItemType::File;
1764
- } else if (type == QLatin1String (" FILE_INFO_TYPE_DIRECTORY" )) {
1766
+ break ;
1767
+ case 1 :
1765
1768
item->type = SyncthingItemType::Directory;
1766
- } else if (type == QLatin1String (" FILE_INFO_TYPE_SYMLINK" )) {
1769
+ break ;
1770
+ case 2 :
1771
+ case 3 :
1772
+ case 4 :
1767
1773
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
+ }
1768
1784
}
1769
1785
readSyncthingItems (children.toArray (), item->children , level + 1 , levels);
1770
1786
item->childrenPopulated = !levels || level < levels;
0 commit comments