db/DatabasePrint: support sorting by "modified-since"

Closes #172
This commit is contained in:
Max Kellermann
2017-12-18 21:36:47 +01:00
parent 7a55ab6acc
commit 5582367d68
5 changed files with 40 additions and 11 deletions

View File

@@ -55,6 +55,19 @@ handle_lsinfo2(Client &client, const char *uri, Response &r)
return CommandResult::OK;
}
static TagType
ParseSortTag(const char *s)
{
if (StringIsEqualIgnoreCase(s, "Last-Modified"))
return TagType(SORT_TAG_LAST_MODIFIED);
TagType tag = tag_name_parse_i(s);
if (tag == TAG_NUM_OF_ITEM_TYPES)
throw ProtocolError(ACK_ERROR_ARG, "Unknown sort tag");
return tag;
}
static CommandResult
handle_match(Client &client, Request args, Response &r, bool fold_case)
{
@@ -76,9 +89,7 @@ handle_match(Client &client, Request args, Response &r, bool fold_case)
++s;
}
sort = tag_name_parse_i(s);
if (sort == TAG_NUM_OF_ITEM_TYPES)
throw ProtocolError(ACK_ERROR_ARG, "Unknown sort tag");
sort = ParseSortTag(s);
args.pop_back();
args.pop_back();