diff -r 7961460e0d9e -r 781aee172901 dav/sync.c --- a/dav/sync.c Wed Mar 16 14:39:59 2016 +0100 +++ b/dav/sync.c Thu Mar 17 15:06:26 2016 +0100 @@ -257,7 +257,7 @@ } // add every resource from the server to svrres - // then db-resources only contains resources which are not on the + // then db-resources contains only resources which are not on the // server LocalResource *local = ucx_map_cstr_get(db->resources, res->path); ucx_map_cstr_put(svrres, res->path, local); @@ -1233,15 +1233,41 @@ return -1; } - printf("Enter webdav repository name.\n"); + printf("Specify webdav repository.\n"); + UcxList *repos = get_repositories(); + int i = 0; + UCX_FOREACH(elm, repos) { + Repository *r = elm->data; + printf("%d) %s\n", i, r->name); + i++; + } char *repository = assistant_getcfg("repository"); + char *reponame = NULL; if(!repository) { fprintf(stderr, "Abort\n"); return -1; } - if(!get_repository(sstr(repository))) { - fprintf(stderr, "Repository %s doesn't exist.\nAbort\n", repository); - return -1; + int64_t reponum = 0; + if(util_strtoint(repository, &reponum)) { + if(reponum < 0) { + fprintf(stderr, "Wrong input.\nAbort\n"); + return -1; + } + UcxList *elm = ucx_list_get(repos, reponum); + if(elm) { + Repository *r = elm->data; + reponame = r->name; + } else { + fprintf(stderr, "Wrong input.\nAbort\n"); + return -1; + } + } else { + if(get_repository(sstr(repository))) { + reponame = repository; + } else { + fprintf(stderr, "Repository %s doesn't exist.\nAbort\n", repository); + return -1; + } } printf("Enter collection relative to the repository base url.\n"); @@ -1253,7 +1279,7 @@ memset(&dir, 0, sizeof(SyncDirectory)); dir.name = name; dir.path = path; - dir.repository = repository; + dir.repository = reponame; dir.collection = collection; dir.trash = ".trash"; dir.database = db;