672 } |
672 } |
673 case REMOTE_CHANGE_MKDIR: { |
673 case REMOTE_CHANGE_MKDIR: { |
674 res_mkdir = ucx_list_append(res_mkdir, res); |
674 res_mkdir = ucx_list_append(res_mkdir, res); |
675 break; |
675 break; |
676 } |
676 } |
|
677 case REMOTE_CHANGE_LINK: { |
|
678 res_link = ucx_list_append(res_link, res); |
|
679 break; |
|
680 } |
677 } |
681 } |
678 |
682 |
679 // remove every server resource from dbres |
683 // remove every server resource from dbres |
680 // all remaining elements are the resources that are removed |
684 // all remaining elements are the resources that are removed |
681 // on the server |
685 // on the server |
805 } |
809 } |
806 |
810 |
807 // download all new, modified and conflict files |
811 // download all new, modified and conflict files |
808 UcxList *download = ucx_list_concat(res_modified, res_conflict); |
812 UcxList *download = ucx_list_concat(res_modified, res_conflict); |
809 download = ucx_list_concat(res_new, download); |
813 download = ucx_list_concat(res_new, download); |
|
814 download = ucx_list_concat(download, res_link); |
810 UCX_FOREACH(elm, download) { |
815 UCX_FOREACH(elm, download) { |
811 DavResource *res = elm->data; |
816 DavResource *res = elm->data; |
812 if(sync_shutdown) { |
817 if(sync_shutdown) { |
813 break; |
818 break; |
814 } |
819 } |
950 REMOTE_CHANGE_MODIFIED : REMOTE_CHANGE_CONFLICT_LOCAL_MODIFIED; |
955 REMOTE_CHANGE_MODIFIED : REMOTE_CHANGE_CONFLICT_LOCAL_MODIFIED; |
951 |
956 |
952 LocalResource *local = ucx_map_cstr_get(db->resources, res->path); |
957 LocalResource *local = ucx_map_cstr_get(db->resources, res->path); |
953 char *local_path = create_local_path(dir, res->path); |
958 char *local_path = create_local_path(dir, res->path); |
954 |
959 |
|
960 char *link = SYNC_SYMLINK(dir) ? |
|
961 dav_get_string_property_ns(res, DAV_NS, "link") : NULL; |
|
962 |
955 SYS_STAT s; |
963 SYS_STAT s; |
956 DavBool exists = 1; |
964 DavBool exists = 1; |
957 if(sys_stat(local_path, &s)) { |
965 if(sys_stat(local_path, &s)) { |
958 if(errno != ENOENT) { |
966 if(errno != ENOENT) { |
959 fprintf(stderr, "Cannot stat file: %s\n", local_path); |
967 fprintf(stderr, "Cannot stat file: %s\n", local_path); |
969 ret = REMOTE_CHANGE_MKDIR; |
977 ret = REMOTE_CHANGE_MKDIR; |
970 } |
978 } |
971 } else if(local) { |
979 } else if(local) { |
972 DavBool nochange = FALSE; |
980 DavBool nochange = FALSE; |
973 char *content_hash = sync_get_content_hash(res); |
981 char *content_hash = sync_get_content_hash(res); |
974 char *link = dav_get_string_property_ns(res, DAV_NS, "link"); |
982 |
975 |
983 if(SYNC_SYMLINK(dir) && nullstrcmp(link, local->link_target)) { |
976 if(nullstrcmp(link, local->link_target)) { |
984 ret = REMOTE_CHANGE_LINK; |
977 ret = REMOTE_CHANGE_MODIFIED; |
985 nochange = TRUE; |
978 } else if(content_hash && local->hash) { |
986 } else if(content_hash && local->hash) { |
979 if(!strcmp(content_hash, local->hash)) { |
987 if(!strcmp(content_hash, local->hash)) { |
980 nochange = TRUE; |
988 nochange = TRUE; |
981 } |
989 } |
982 } else if(local->etag) { |
990 } else if(local->etag) { |