From 2a02c6ede6c91944fab8068cc623b8ecef616000 Mon Sep 17 00:00:00 2001 From: emeric Date: Sun, 28 Jul 2024 13:43:07 +0200 Subject: [PATCH] Fixed xml attributes sometimes not written --- src/libs/subsonic/impl/SubsonicResponse.cpp | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/libs/subsonic/impl/SubsonicResponse.cpp b/src/libs/subsonic/impl/SubsonicResponse.cpp index 993e2dfc..90ae1faf 100644 --- a/src/libs/subsonic/impl/SubsonicResponse.cpp +++ b/src/libs/subsonic/impl/SubsonicResponse.cpp @@ -193,18 +193,6 @@ namespace lms::api::subsonic std::function nodeToPropertyTree = [&](const Node& node) { boost::property_tree::ptree res; - for (const auto& [key, value] : node._attributes) - { - if (std::holds_alternative(value)) - res.put("." + std::string{ key.str() }, std::get(value)); - else if (std::holds_alternative(value)) - res.put("." + std::string{ key.str() }, std::get(value)); - else if (std::holds_alternative(value)) - res.put("." + std::string{ key.str() }, std::get(value)); - else if (std::holds_alternative(value)) - res.put("." + std::string{ key.str() }, std::get(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(value)) + res.put("." + std::string{ key.str() }, std::get(value)); + else if (std::holds_alternative(value)) + res.put("." + std::string{ key.str() }, std::get(value)); + else if (std::holds_alternative(value)) + res.put("." + std::string{ key.str() }, std::get(value)); + else if (std::holds_alternative(value)) + res.put("." + std::string{ key.str() }, std::get(value)); + else + assert(false); + } + return res; };