Fixed xml attributes sometimes not written

This commit is contained in:
emeric
2024-07-28 13:43:07 +02:00
parent b3807f6a53
commit 2a02c6ede6
+14 -12
View File
@@ -193,18 +193,6 @@ namespace lms::api::subsonic
std::function<boost::property_tree::ptree(const Node&)> nodeToPropertyTree = [&](const Node& node) {
boost::property_tree::ptree res;
for (const auto& [key, value] : node._attributes)
{
if (std::holds_alternative<Node::string>(value))
res.put("<xmlattr>." + std::string{ key.str() }, std::get<Node::string>(value));
else if (std::holds_alternative<bool>(value))
res.put("<xmlattr>." + std::string{ key.str() }, std::get<bool>(value));
else if (std::holds_alternative<float>(value))
res.put("<xmlattr>." + std::string{ key.str() }, std::get<float>(value));
else if (std::holds_alternative<long long>(value))
res.put("<xmlattr>." + std::string{ key.str() }, std::get<long long>(value));
}
auto valueToPropertyTree = [](const Node::ValueType& value) {
boost::property_tree::ptree res;
std::visit([&](const auto& rawValue) {
@@ -239,6 +227,20 @@ namespace lms::api::subsonic
}
}
for (const auto& [key, value] : node._attributes)
{
if (std::holds_alternative<Node::string>(value))
res.put("<xmlattr>." + std::string{ key.str() }, std::get<Node::string>(value));
else if (std::holds_alternative<bool>(value))
res.put("<xmlattr>." + std::string{ key.str() }, std::get<bool>(value));
else if (std::holds_alternative<float>(value))
res.put("<xmlattr>." + std::string{ key.str() }, std::get<float>(value));
else if (std::holds_alternative<long long>(value))
res.put("<xmlattr>." + std::string{ key.str() }, std::get<long long>(value));
else
assert(false);
}
return res;
};