adds dav-sync archive command

Thu, 07 Sep 2017 18:18:30 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 07 Sep 2017 18:18:30 +0200
changeset 299
c517502d3e38
parent 298
755b8198b071
child 300
4e3769d4e782

adds dav-sync archive command

dav/sync.c file | annotate | diff | comparison | revisions
dav/sync.h file | annotate | diff | comparison | revisions
dav/version.h file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Tue Sep 05 17:25:09 2017 +0200
+++ b/dav/sync.c	Thu Sep 07 18:18:30 2017 +0200
@@ -100,7 +100,9 @@
         if(!strcmp(cmd, "pull")) {
             ret = cmd_pull(args);
         } else if(!strcmp(cmd, "push")) {
-            ret = cmd_push(args);
+            ret = cmd_push(args, FALSE);
+        } else if(!strcmp(cmd, "archive")) {
+            ret = cmd_push(args, TRUE);
         } else if(!strcmp(cmd, "resolve-conflicts")) {
             ret = cmd_resolve_conflicts(args);
         } else if(!strcmp(cmd, "delete-conflicts")) {
@@ -142,6 +144,7 @@
     fprintf(stderr, "Commands:\n");
     fprintf(stderr, "        pull [-cld] <directory>\n");
     fprintf(stderr, "        push [-cld] <directory>\n");
+    fprintf(stderr, "        archive [-cld] <directory>\n");
     fprintf(stderr, "        resolve-conflicts <directory>\n");
     fprintf(stderr, "        delete-conflicts <directory>\n");
     fprintf(stderr, "        trash-info <directory>\n");
@@ -735,7 +738,7 @@
     return ucx_map_cstr_get(db->conflict, res->path) ? 1 : 0;
 }
 
-int cmd_push(CmdArgs *a) {
+int cmd_push(CmdArgs *a, DavBool archive) {
     if(a->argc != 1) {
         fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many");
         return -1;
@@ -878,7 +881,7 @@
     }
     
     // delete all removed files
-    if(ret == 0) {
+    if(ret == 0 && !archive) {
         UcxMapIterator i = ucx_map_iterator(db->resources);
         LocalResource *local;
         UCX_MAP_FOREACH(key, local, i) {
@@ -935,11 +938,13 @@
         char *str_delete = sync_delete == 1 ? "file" : "files";
         char *str_skipped = sync_delete == 1 ? "file" : "files";
         char *str_error = sync_error == 1 ? "error" : "errors";
-        printf("Result: %d %s pushed, %d %s deleted, %d %s skipped, %d %s\n",
-                sync_success, str_success,
-                sync_delete,str_delete,
-                sync_skipped,str_skipped,
-                sync_error, str_error);
+        
+        printf("Result: %d %s pushed, ", sync_success, str_success);
+        if(!archive) {
+            printf("%d %s deleted, ", sync_delete, str_delete);
+        }
+        printf("%d %s skipped, %d %s\n",
+                sync_skipped, str_skipped, sync_error, str_error);
     }
     
     return ret;
--- a/dav/sync.h	Tue Sep 05 17:25:09 2017 +0200
+++ b/dav/sync.h	Thu Sep 07 18:18:30 2017 +0200
@@ -46,7 +46,7 @@
 void print_usage(char *cmd);
 
 int cmd_pull(CmdArgs *args);
-int cmd_push(CmdArgs *args);
+int cmd_push(CmdArgs *args, DavBool archive);
 
 int sync_get_resource(
         CmdArgs *a,
--- a/dav/version.h	Tue Sep 05 17:25:09 2017 +0200
+++ b/dav/version.h	Thu Sep 07 18:18:30 2017 +0200
@@ -29,7 +29,7 @@
 #ifndef VERSION_H
 #define VERSION_H
 
-#define DAV_VERSION "1.0.0"
+#define DAV_VERSION "1.0 dev"
 
 #endif /* VERSION_H */
 

mercurial