dav/sync.c

branch
v1.0
changeset 303
5d79c108fcab
parent 294
dd5c0ebdf54f
--- a/dav/sync.c	Thu Sep 07 18:42:51 2017 +0200
+++ b/dav/sync.c	Sun Sep 10 10:37:51 2017 +0200
@@ -865,7 +865,7 @@
         UCX_MAP_FOREACH(key, local, i) {
             if (!res_matches_filter(dir, local->path+1)) {
                 if(sync_delete_remote_resource(sn, local, &sync_delete)) {
-                    ucx_map_cstr_put(lclres, local->path, local);
+                    ucx_map_cstr_put(lclres, local->path, local_resource_copy(local));
                     if(sn->error != DAV_NOT_FOUND) {
                         print_resource_error(sn, local->path);
                         sync_error++;
@@ -1040,6 +1040,24 @@
     }
 }
 
+LocalResource* local_resource_copy(LocalResource *res) {
+    LocalResource *newres = calloc(1, sizeof(LocalResource));
+    if(res->name) {
+        newres->name = strdup(res->name);
+    }
+    if(res->path) {
+        newres->path = strdup(res->path);
+    }
+    if(res->etag) {
+        newres->etag = strdup(res->etag);
+    }
+    newres->skipped = res->skipped;
+    newres->size = res->size;
+    newres->last_modified = res->last_modified;
+    newres->isdirectory = res->isdirectory;
+    return newres;
+}
+
 int local_resource_is_changed(SyncDirectory *dir, SyncDatabase *db, LocalResource *res) {
     LocalResource *db_res = ucx_map_cstr_get(db->resources, res->path);
     if(db_res) {

mercurial