fixes control flow in cmd_push()

Sun, 11 Nov 2018 17:22:16 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 11 Nov 2018 17:22:16 +0100
changeset 493
75a259ec8dea
parent 492
7bde663719dc
child 494
3aed354185eb

fixes control flow in cmd_push()

dav/sync.c file | annotate | diff | comparison | revisions
libidav/resource.c file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Fri Nov 09 18:03:17 2018 +0100
+++ b/dav/sync.c	Sun Nov 11 17:22:16 2018 +0100
@@ -1083,7 +1083,7 @@
     //UcxList *resources = cmd_getoption(a, "read") ?
     //        read_changes(dir, db) : local_scan(dir, db);
     UcxList *resources = local_scan(dir, db);
-    
+       
     UcxMap *lclres = ucx_map_new(db->resources->count);
     int ret = 0;
     UCX_FOREACH(elm, resources) {
@@ -1145,40 +1145,37 @@
                     sync_error++;
                 }
                 
-                if(local_res->isdirectory || !is_changed) {
-                    // only check existence if the resource is supposed
-                    // to be a collection
-                    int exists = local_res->isdirectory ? dav_exists(res) : 1;
-                    
-                    // continue if the resource exists or is not found
-                    // because a 404 is not an unexpected error
-                    if(exists || sn->error == DAV_NOT_FOUND) {
+                if(local_res->isdirectory) {
+                    dav_exists(res);
+                    if(sn->error == DAV_NOT_FOUND) {
                         int abort = 0;
-                        if(!exists) {
-                            // make sure to store tags for newly created cols
-                            local_res->tags_updated = 1;
-                            // create collection
-                            // TODO: show 405
-                            printf("mkcol: %s\n", local_res->path);
-                            if(sync_mkdir(dir, res, local_res) && sn->error != DAV_METHOD_NOT_ALLOWED) {
-                                print_resource_error(sn, res->path);
-                                ret = -1;
-                                sync_error++;
-                                error = 1;
-                                abort = 1;
-                            }
+                        // make sure to store tags for newly created cols
+                        local_res->tags_updated = 1;
+                        // create collection
+                        // TODO: show 405
+                        printf("mkcol: %s\n", local_res->path);
+                        if(sync_mkdir(dir, res, local_res) && sn->error != DAV_METHOD_NOT_ALLOWED) {
+                            print_resource_error(sn, res->path);
+                            ret = -1;
+                            sync_error++;
+                            error = 1;
+                            abort = 1;
                         }
                         
                         if(dir->tagconfig && local_res->tags_updated && !abort) {
                             sync_update_tags(dir, sn, res, local_res);
                         }
-                    } else {
+                    } else if(sn->error != DAV_OK) {
                         // dav_exists() failed
                         print_resource_error(sn, local_res->path);
                         ret = -1;
                         sync_error++;
                         error = 1;
                     }
+                } else if(!is_changed) {
+                    if(dir->tagconfig && local_res->tags_updated) {
+                        sync_update_tags(dir, sn, res, local_res);
+                    }
                 } else {
                     if(cdt && remote_resource_is_changed(sn, dir, db, local_res)) {
                         printf("conflict: %s\n", local_res->path);
--- a/libidav/resource.c	Fri Nov 09 18:03:17 2018 +0100
+++ b/libidav/resource.c	Sun Nov 11 17:22:16 2018 +0100
@@ -1028,6 +1028,8 @@
 }
 
 int dav_exists(DavResource *res) {
+    // TODO: reimplement with PROPFIND
+    
     DavSession *sn = res->session;
     CURL *handle = sn->handle;
     util_set_url(sn, dav_resource_get_href(res));

mercurial