fix missing cmd_add_directory() implementation after ucx upgrade

Sun, 17 Dec 2023 15:22:34 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 17 Dec 2023 15:22:34 +0100
changeset 799
d479b5e25b6e
parent 798
d7f5067a27ce
child 800
30d484806c2b

fix missing cmd_add_directory() implementation after ucx upgrade

dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Sun Dec 17 15:03:01 2023 +0100
+++ b/dav/sync.c	Sun Dec 17 15:22:34 2023 +0100
@@ -5609,18 +5609,14 @@
 
 
 int cmd_add_directory(CmdArgs *args) {
-    /*
-    if(!get_repositories()) {
+    DavConfig *davconfig = get_config();
+
+    if(!davconfig->repositories) {
         fprintf(stderr, "No repositories available. Run 'dav add-repository' first.\n");
         fprintf(stderr, "Abort\n");
         return -1;
     }
-    */
-    
-    // TODO: port to ucx 3
-    return 1;
-#if 0
-    
+
     log_printf("Each sync directory must have an unique name.\n");
     char *name = assistant_getcfg("name");
     if(!name) {
@@ -5640,10 +5636,9 @@
     }
     
     log_printf("Specify webdav repository.\n");
-    CxIterator repos = get_repositories();
     int i = 0;
-    cx_foreach(Repository *, r, repos) {
-        log_printf("%d) %s\n", i, r->name);
+    for (DavCfgRepository *r = davconfig->repositories; r != NULL; r = r->next) {
+        log_printf("%d) %s\n", i, r->name.value.ptr);
         i++;
     }
     char *repository = assistant_getcfg("repository");
@@ -5658,16 +5653,17 @@
             fprintf(stderr, "Wrong input.\nAbort\n");
             return -1;
         }
-        UcxList *elm = ucx_list_get(repos, reponum);
-        if(elm) {
-            Repository *r = elm->data;
-            reponame = r->name;
+        DavCfgRepository *r = cx_linked_list_at(davconfig->repositories, 0,
+                                                offsetof(DavCfgRepository, next),
+                                                reponum);
+        if(r != NULL) {
+            reponame = r->name.value.ptr;
         } else {
             fprintf(stderr, "Wrong input.\nAbort\n");
             return -1;
         }
     } else {
-        if(get_repository(sstr(repository))) {
+        if(dav_config_get_repository(davconfig, cx_str(repository))) {
             reponame = repository;
         } else {
             fprintf(stderr, "Repository %s doesn't exist.\nAbort\n", repository);
@@ -5704,7 +5700,6 @@
     free(db);
     
     return ret;
-#endif
 }
 
 int cmd_list_dirs() {

mercurial