diff options
author | Max Kellermann <max@musicpd.org> | 2018-10-22 11:35:22 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-10-22 13:08:24 +0200 |
commit | db27bb76e280c69d70bc14f0b0161e89d496a3c8 (patch) | |
tree | 6efdf274058eea88b99ac92155aae1d7e83e03c6 /src/command | |
parent | 7cfe929c3692e74f4e6073960eaf0e08a9989811 (diff) |
db: fix broken command "list ... group"
Grouping in the "list" command was completely broken from the start,
unlike "count group". I have no idea what I have been thinking when I
wrote commit ae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49, but it didn't
make any sense.
This commit is a rewrite of the feature.
For clients to be able to detect this feature, this commit also
increments the protocol version.
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/DatabaseCommands.cxx | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx index 42f79b8e2..3f7d18324 100644 --- a/src/command/DatabaseCommands.cxx +++ b/src/command/DatabaseCommands.cxx @@ -191,7 +191,7 @@ handle_list(Client &client, Request args, Response &r) } std::unique_ptr<SongFilter> filter; - tag_mask_t group_mask = 0; + TagType group = TAG_NUM_OF_ITEM_TYPES; if (args.size == 1) { /* for compatibility with < 0.12.0 */ @@ -206,18 +206,16 @@ handle_list(Client &client, Request args, Response &r) args.shift())); } - while (args.size >= 2 && - StringIsEqual(args[args.size - 2], "group")) { + if (args.size >= 2 && + StringIsEqual(args[args.size - 2], "group")) { const char *s = args[args.size - 1]; - TagType gt = tag_name_parse_i(s); - if (gt == TAG_NUM_OF_ITEM_TYPES) { + 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; } - group_mask |= tag_mask_t(1) << unsigned(gt); - args.pop_back(); args.pop_back(); } @@ -230,14 +228,13 @@ handle_list(Client &client, Request args, Response &r) } } - if (tagType < TAG_NUM_OF_ITEM_TYPES && - group_mask & (tag_mask_t(1) << tagType)) { + if (tagType < TAG_NUM_OF_ITEM_TYPES && tagType == group) { r.Error(ACK_ERROR_ARG, "Conflicting group"); return CommandResult::ERROR; } PrintUniqueTags(r, client.partition, - tagType, group_mask, filter.get()); + tagType, group, filter.get()); return CommandResult::OK; } |