diff -r 9c486ea25161 -r e94bf8530d56 dav/sync.c --- a/dav/sync.c Thu Jul 03 16:16:02 2014 +0200 +++ b/dav/sync.c Fri Jul 04 12:09:48 2014 +0200 @@ -179,6 +179,11 @@ } int sync_get_resource(SyncDirectory *dir, DavResource *res, SyncDatabase *db) { + LocalResource *removed = ucx_map_cstr_get(db->remove, res->path); + if(removed) { + return 0; + } + LocalResource *local = ucx_map_cstr_get(db->resources, res->path); char *local_path = util_concat_path(dir->path, res->path); @@ -306,6 +311,7 @@ dav_session_set_flags(sn, get_repository_flags(repo)); sn->key = dav_context_get_key(ctx, repo->default_key); + // upload all changed files UcxList *resources = local_scan(dir, db); UCX_FOREACH(elm, resources) { char *path = elm->data; @@ -317,6 +323,24 @@ } ucx_list_free(resources); + // delete all removed files + UcxMapIterator i = ucx_map_iterator(db->remove); + LocalResource *local; + UCX_MAP_FOREACH(key, local, i) { + DavResource *res = dav_resource_new(sn, local->path); + printf("delete: %s\n", res->path); + if(dav_delete(res)) { + if(sn->error != DAV_NOT_FOUND) { + fprintf(stderr, "Cannot delete resource %s\n", res->path); + } + } + dav_resource_free(res); + // TODO: free local resource + ucx_map_remove(db->remove, key); + } + + // TODO: free res + // store db if(store_db(db, dir->database)) { fprintf(stderr, "Cannot store sync db\n");