fix order of dir deletions in dav-sync pull

Thu, 15 Aug 2019 19:38:52 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 15 Aug 2019 19:38:52 +0200
changeset 626
2f735b0e87fa
parent 625
e1a85fbf68f9
child 627
81e066c9ff87

fix order of dir deletions in dav-sync pull

dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Wed Aug 14 21:13:28 2019 +0200
+++ b/dav/sync.c	Thu Aug 15 19:38:52 2019 +0200
@@ -895,9 +895,13 @@
     }
     ucx_map_free(lres_removed);
     
+    // sort dir list, we need to delete dirs with higher depth first
+    rmdirs = ucx_list_sort(rmdirs, (cmp_func)resource_pathlen_cmp, NULL);
+    // delete dirs
     UCX_FOREACH(elm, rmdirs) {
         LocalResource *local_dir = elm->data;
         if(!sync_remove_local_directory(dir, local_dir)) {
+            // dir successfully removed, now remove the related db entry
             LocalResource *local = ucx_map_cstr_remove(db->resources, local_dir->path);
             if(local) {
                 local_resource_free(local);

mercurial