Skip to content

Commit ec6afed

Browse files
committed
feat: unification of category keys in WebAPI
This PR introduces two new keys for maindata response namely downloadPath and downloadPathEnabled. in editCategory/createCategory we take these keys to set category download_path but while returning the in maindata response we are sending download_path and this fails for type strict application as this same key return false or path based on if the download_path is enabled or not. leaving the download_path as is as there might be applications which consume the download_path. (can remove if needed) closes #23780
1 parent b3ddcac commit ec6afed

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/webui/api/synccontroller.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,20 @@ void SyncController::makeMaindataSnapshot()
604604
QJsonObject category = categoryOptions.toJSON();
605605
// adjust it to be compatible with existing WebAPI
606606
category[u"savePath"_s] = category.take(u"save_path"_s);
607+
// As editCategory/createCategory use downloadPathEnabled and downlaodPath as parameter to set the value
608+
// maindata should return the same keys in category section.
609+
QJsonValue downloadPathVal = category.value(u"download_path"_s);
610+
if (downloadPathVal.isString() && !downloadPathVal.toString().isEmpty())
611+
{
612+
category[u"downloadPathEnabled"_s] = true;
613+
category[u"downloadPath"_s] = downloadPathVal.toString();
614+
}
615+
else
616+
{
617+
category[u"downloadPathEnabled"_s] = false;
618+
category[u"downloadPath"_s] = QJsonValue::Null;
619+
}
620+
607621
category.insert(u"name"_s, categoryName);
608622
m_maindataSnapshot.categories[categoryName] = category.toVariantMap();
609623
}
@@ -657,6 +671,19 @@ QJsonObject SyncController::generateMaindataSyncData(const int id, const bool fu
657671
// adjust it to be compatible with existing WebAPI
658672
category[u"savePath"_s] = category.take(u"save_path"_s);
659673
category.insert(u"name"_s, categoryName);
674+
// As editCategory/createCategory use downloadPathEnabled and downlaodPath as parameter to set the value
675+
// maindata should return the same keys in category section.
676+
QVariant downloadPathVal = category.value(u"download_path"_s);
677+
if ((downloadPathVal.typeId() == QMetaType::QString) && !downloadPathVal.toString().isEmpty())
678+
{
679+
category[u"downloadPathEnabled"_s] = true;
680+
category[u"downloadPath"_s] = downloadPathVal.toString();
681+
}
682+
else
683+
{
684+
category[u"downloadPathEnabled"_s] = false;
685+
category[u"downloadPath"_s] = QVariant();
686+
}
660687

661688
auto &categorySnapshot = m_maindataSnapshot.categories[categoryName];
662689
if (const QVariantMap syncData = processMap(categorySnapshot, category); !syncData.isEmpty())

0 commit comments

Comments
 (0)