# HG changeset patch # User Olaf Wintermann # Date 1505032671 -7200 # Node ID 5d79c108fcab05a4af8c05f133779936ac7b23cb # Parent cbea102875a86b146633834430fa0bf48ef0985d fixes crash when dav-sync push can't delete a resource on the server diff -r cbea102875a8 -r 5d79c108fcab dav/sync.c --- 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) { diff -r cbea102875a8 -r 5d79c108fcab dav/sync.h --- a/dav/sync.h Thu Sep 07 18:42:51 2017 +0200 +++ b/dav/sync.h Sun Sep 10 10:37:51 2017 +0200 @@ -62,6 +62,7 @@ UcxList* local_scan(SyncDirectory *dir, SyncDatabase *db); UcxList* read_changes(SyncDirectory *dir, SyncDatabase *db); LocalResource* local_resource_new(SyncDirectory *dir, SyncDatabase *db, char *path, int *isdir); +LocalResource* local_resource_copy(LocalResource *res); int local_resource_is_changed(SyncDirectory *dir, SyncDatabase *db, LocalResource *res); int remote_resource_is_changed( DavSession *sn,