adds option to sort dav list by lastmodified date

Tue, 05 Sep 2017 16:03:48 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 05 Sep 2017 16:03:48 +0200
changeset 297
3cbe57eeaed1
parent 296
bb49953b1cf8
child 298
755b8198b071

adds option to sort dav list by lastmodified date

dav/main.c file | annotate | diff | comparison | revisions
dav/optparser.c file | annotate | diff | comparison | revisions
--- 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);
--- 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;

mercurial