adds -R and -M option to restore command

Tue, 19 Mar 2019 19:24:25 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 19 Mar 2019 19:24:25 +0100
changeset 528
4c9c8c017d52
parent 527
d0e37224eba1
child 529
dc3f82b04733

adds -R and -M option to restore command

dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Tue Mar 19 19:14:48 2019 +0100
+++ b/dav/sync.c	Tue Mar 19 19:24:25 2019 +0100
@@ -1579,6 +1579,13 @@
         return -1;
     }
     
+    DavBool restore_modified = cmd_getoption(a, "restore-modified") ? 1 : 0;
+    DavBool restore_removed = cmd_getoption(a, "restore-removed") ? 1 : 0;
+    if(!restore_modified && !restore_removed) {
+        restore_modified = 1;
+        restore_removed = 1;
+    }
+    
     SyncDatabase *db = load_db(dir->database);
     if(!db) {
         fprintf(stderr, "Cannot load database file: %s\n", dir->database);
@@ -1602,14 +1609,18 @@
         SYS_STAT s;
         if(sys_stat(file_path, &s)) {
             if(errno == ENOENT) {
-                deleted = ucx_list_prepend(deleted, resource);
+                if(restore_removed) {
+                    deleted = ucx_list_prepend(deleted, resource);
+                }
             } else {
                 fprintf(stderr, "Cannot stat file: %s\n", file_path);
                 perror("");
             }
         } else if(!resource->isdirectory && !S_ISDIR(s.st_mode)) {
             if(resource->last_modified != s.st_mtime || resource->size != s.st_size) {
-                modified = ucx_list_prepend(modified, resource);
+                if(restore_modified) {
+                    modified = ucx_list_prepend(modified, resource);
+                }
             }
         }
 

mercurial