# HG changeset patch # User Olaf Wintermann # Date 1407155636 -7200 # Node ID 99f7816fcf011e8ac8c9e13eac6fedc24a1738d6 # Parent 4cb389452a44ad6ae773ae8c141f5cfd4bf105b9 added collection config for sync directories diff -r 4cb389452a44 -r 99f7816fcf01 dav/scfg.c --- a/dav/scfg.c Mon Aug 04 12:53:36 2014 +0200 +++ b/dav/scfg.c Mon Aug 04 14:33:56 2014 +0200 @@ -79,6 +79,7 @@ int scfg_load_directory(xmlNode *node) { char *name = NULL; char *path = NULL; + char *collection = NULL; char *repository = NULL; char *database = NULL; @@ -92,6 +93,8 @@ name = value; } else if(xstreq(node->name, "path")) { path = value; + } else if(xstreq(node->name, "collection")) { + collection = value; } else if(xstreq(node->name, "repository")) { repository = value; } else if(xstreq(node->name, "database")) { @@ -121,6 +124,7 @@ SyncDirectory *dir = malloc(sizeof(SyncDirectory)); dir->name = strdup(name); dir->path = strdup(path); + dir->collection = collection ? strdup(collection) : NULL; dir->repository = strdup(repository); dir->database = strdup(database); diff -r 4cb389452a44 -r 99f7816fcf01 dav/scfg.h --- a/dav/scfg.h Mon Aug 04 12:53:36 2014 +0200 +++ b/dav/scfg.h Mon Aug 04 14:33:56 2014 +0200 @@ -40,6 +40,7 @@ typedef struct SyncDirectory { char *name; char *path; + char *collection; char *repository; char *database; } SyncDirectory; diff -r 4cb389452a44 -r 99f7816fcf01 dav/sync.c --- a/dav/sync.c Mon Aug 04 12:53:36 2014 +0200 +++ b/dav/sync.c Mon Aug 04 14:33:56 2014 +0200 @@ -130,11 +130,18 @@ return -1; } + char *new_url = NULL; + if(dir->collection) { + new_url = util_concat_path(repo->url, dir->collection); + } DavSession *sn = dav_session_new_auth( ctx, - repo->url, + new_url ? new_url : repo->url, repo->user, repo->password); + if(new_url) { + free(new_url); + } dav_session_set_flags(sn, get_repository_flags(repo)); sn->key = dav_context_get_key(ctx, repo->default_key); @@ -372,11 +379,18 @@ return -1; } + char *new_url = NULL; + if(dir->collection) { + new_url = util_concat_path(repo->url, dir->collection); + } DavSession *sn = dav_session_new_auth( ctx, - repo->url, + new_url ? new_url : repo->url, repo->user, repo->password); + if(new_url) { + free(new_url); + } dav_session_set_flags(sn, get_repository_flags(repo)); sn->key = dav_context_get_key(ctx, repo->default_key);