dav/sync.c

changeset 614
e72d2b99b0f6
parent 613
f6072141f5ee
child 615
ab669d21f82a
--- a/dav/sync.c	Sat Aug 10 13:48:14 2019 +0200
+++ b/dav/sync.c	Sat Aug 10 14:25:03 2019 +0200
@@ -1878,6 +1878,15 @@
         } else if(local_res->metadata_updated) {
             ls_update = ucx_list_append(ls_update, local_res);
         }
+        
+        if(local_res->isnew) {
+            if(local_resource_load_metadata(dir, local_res)) {
+                fprintf(
+                        stderr,
+                        "Failed to load metadata: %s\n",
+                        local_resource_path(local_res));
+            }
+        }
     }
     
     if(dir->hashing) {
@@ -2713,7 +2722,7 @@
         }
         
         if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) {
-            char *path = create_local_path(dir, db_res->path);
+            char *path = create_local_path(dir, local_resource_path(db_res));
             XAttributes *xattr = file_get_attributes(path);
             // test if xattr are added, removed or changed
             if((db_res->xattr_hash && !xattr) ||
@@ -2800,6 +2809,18 @@
     return ret;
 }
 
+int local_resource_load_metadata(SyncDirectory *dir, LocalResource *res) {
+    // currently only xattr needed
+    if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) {
+        char *path = create_local_path(dir, local_resource_path(res));
+        XAttributes *xattr = file_get_attributes(path);
+        res->xattr = xattr;
+        free(path);
+    }
+    
+    return 0;
+}
+
 char* resource_local_path(DavResource *res) {
 #ifdef SYS_LINK_EXT
     // on Windows, add .lnk extension to links

mercurial