dav/sync.c

changeset 580
caf23cf7f96d
parent 579
c80d5730c00b
child 581
3f9a9c80a2d2
equal deleted inserted replaced
579:c80d5730c00b 580:caf23cf7f96d
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) {
993 if(!nochange) { 1001 if(!nochange) {
994 if(!(exists && s.st_mtime != local->last_modified)) { 1002 if(!(exists && s.st_mtime != local->last_modified)) {
995 type = REMOTE_CHANGE_MODIFIED; 1003 type = REMOTE_CHANGE_MODIFIED;
996 } 1004 }
997 ret = type; 1005 ret = type;
1006 }
1007 } else if(link) {
1008 if(type == REMOTE_CHANGE_CONFLICT_LOCAL_MODIFIED) {
1009 ret = REMOTE_CHANGE_CONFLICT_LOCAL_MODIFIED;
1010 } else {
1011 ret = REMOTE_CHANGE_LINK;
998 } 1012 }
999 } else if(exists) { 1013 } else if(exists) {
1000 ret = type; 1014 ret = type;
1001 } else { 1015 } else {
1002 ret = REMOTE_CHANGE_NEW; 1016 ret = REMOTE_CHANGE_NEW;

mercurial