# HG changeset patch # User Olaf Wintermann # Date 1504620228 -7200 # Node ID 3cbe57eeaed188068030ddbb0ce54fcc16efcc8a # Parent bb49953b1cf815d65b09abfe65a83f91a5bc4f1c adds option to sort dav list by lastmodified date diff -r bb49953b1cf8 -r 3cbe57eeaed1 dav/main.c --- a/dav/main.c Tue Sep 05 13:07:29 2017 +0200 +++ b/dav/main.c Tue Sep 05 16:03:48 2017 +0200 @@ -350,6 +350,9 @@ return sn; } +#define LIST_QUERY_ORDER_BY_NAME "select `idav:crypto-name`,`idav:crypto-key`,D:lockdiscovery,apache:executable from %s with depth = %d where lastmodified > %t order by iscollection desc, name" +#define LIST_QUERY_ORDER_BY_DATE "select `idav:crypto-name`,`idav:crypto-key`,D:lockdiscovery,apache:executable from %s with depth = %d where lastmodified > %t order by iscollection desc, lastmodified desc" + int cmd_list(CmdArgs *a) { if(a->argc != 1) { fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few":"many"); @@ -366,6 +369,7 @@ } char *update = cmd_getoption(a, "update"); + char *date = cmd_getoption(a, "date"); time_t t = -1; if(update) { t = util_parse_lastmodified(update); @@ -377,7 +381,7 @@ while(ret != 0) { ls = dav_query( sn, - "select `idav:crypto-name`,`idav:crypto-key`,D:lockdiscovery,apache:executable from %s with depth = %d where lastmodified > %t order by iscollection desc, name", + date ? LIST_QUERY_ORDER_BY_DATE : LIST_QUERY_ORDER_BY_NAME, path, depth, t); diff -r bb49953b1cf8 -r 3cbe57eeaed1 dav/optparser.c --- a/dav/optparser.c Tue Sep 05 13:07:29 2017 +0200 +++ b/dav/optparser.c Tue Sep 05 16:03:48 2017 +0200 @@ -95,6 +95,10 @@ ucx_map_cstr_put(a->options, "list", NOARG); break; } + case 'd': { + ucx_map_cstr_put(a->options, "date", NOARG); + break; + } case 't': { ucx_map_cstr_put(a->options, "type", NOARG); break;