diff options
author | Max Kellermann <max@musicpd.org> | 2019-06-17 22:06:54 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-06-17 22:06:54 +0200 |
commit | 33f5e03e80a78ceae89c09801271f2975c04e1e3 (patch) | |
tree | f91c03fa5d6704311b8eee387e09b0d8d886b375 /src/command | |
parent | fd7caab872f29e079f6d27418271084b62213754 (diff) | |
parent | 2c3eeb7194b4871ed7227a2c0b7bfae90b05d17f (diff) |
Merge branch 'v0.21.x'
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/DatabaseCommands.cxx | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx index 75dec137a..2b62c54a9 100644 --- a/src/command/DatabaseCommands.cxx +++ b/src/command/DatabaseCommands.cxx @@ -260,7 +260,7 @@ handle_list(Client &client, Request args, Response &r) } std::unique_ptr<SongFilter> filter; - TagType group = TAG_NUM_OF_ITEM_TYPES; + std::vector<TagType> tag_types; if (args.size == 1 && /* parantheses are the syntax for filter expressions: no @@ -278,20 +278,31 @@ handle_list(Client &client, Request args, Response &r) args.shift())); } - if (args.size >= 2 && - StringIsEqual(args[args.size - 2], "group")) { + while (args.size >= 2 && + StringIsEqual(args[args.size - 2], "group")) { const char *s = args[args.size - 1]; - group = tag_name_parse_i(s); + const auto group = tag_name_parse_i(s); if (group == TAG_NUM_OF_ITEM_TYPES) { r.FormatError(ACK_ERROR_ARG, "Unknown tag type: %s", s); return CommandResult::ERROR; } + if (group == tagType || + std::find(tag_types.begin(), tag_types.end(), + group) != tag_types.end()) { + r.Error(ACK_ERROR_ARG, "Conflicting group"); + return CommandResult::ERROR; + } + + tag_types.emplace_back(group); + args.pop_back(); args.pop_back(); } + tag_types.emplace_back(tagType); + if (!args.empty()) { filter.reset(new SongFilter()); try { @@ -304,13 +315,9 @@ handle_list(Client &client, Request args, Response &r) filter->Optimize(); } - if (tagType < TAG_NUM_OF_ITEM_TYPES && tagType == group) { - r.Error(ACK_ERROR_ARG, "Conflicting group"); - return CommandResult::ERROR; - } - PrintUniqueTags(r, client.GetPartition(), - tagType, group, filter.get()); + {&tag_types.front(), tag_types.size()}, + filter.get()); return CommandResult::OK; } |