fix dav-sync add-tag in case a file is not in the db

Wed, 23 Oct 2019 20:24:40 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 23 Oct 2019 20:24:40 +0200
changeset 669
152101df336d
parent 668
6df5ebb00841
child 670
ef490647f5d1

fix dav-sync add-tag in case a file is not in the db

dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Wed Oct 23 20:10:55 2019 +0200
+++ b/dav/sync.c	Wed Oct 23 20:24:40 2019 +0200
@@ -4955,7 +4955,13 @@
         return -1;
     }
     
+    LocalResource *newres = NULL;
     LocalResource *localres = ucx_map_cstr_get(db->resources, file.path);
+    if(!localres) {
+        newres = calloc(1, sizeof(LocalResource));
+        newres->path = strdup(file.path);
+        localres = newres;
+    }
     UcxList *tags = NULL;
     DavBool store_tags = FALSE;
     
@@ -5019,6 +5025,10 @@
         }
     }
     
+    if(newres) {
+        local_resource_free(newres);
+    }
+    
     // store db
     if(store_db(db, file.dir->database, file.dir->db_settings)) {
         fprintf(stderr, "Cannot store sync db\n");

mercurial