dav/sync.c

changeset 639
928a77ebe0b9
parent 638
b3077bdb3d77
child 643
5b8643cf0a2f
equal deleted inserted replaced
638:b3077bdb3d77 639:928a77ebe0b9
2079 int origin_changed = remote_resource_is_changed( 2079 int origin_changed = remote_resource_is_changed(
2080 sn, 2080 sn,
2081 dir, 2081 dir,
2082 db, 2082 db,
2083 origin_res, 2083 origin_res,
2084 local->origin); 2084 local->origin,
2085 NULL);
2085 if(origin_changed) { 2086 if(origin_changed) {
2086 // upload with put 2087 // upload with put
2087 ls_modified = ucx_list_prepend(ls_modified, local); 2088 ls_modified = ucx_list_prepend(ls_modified, local);
2088 } else { 2089 } else {
2089 printf("%s: %s -> %s\n", copy ? "copy":"move", local->origin->path, local->path); 2090 printf("%s: %s -> %s\n", copy ? "copy":"move", local->origin->path, local->path);
2125 if(!res) { 2126 if(!res) {
2126 print_resource_error(sn, local_res->path); 2127 print_resource_error(sn, local_res->path);
2127 ret = -1; 2128 ret = -1;
2128 sync_error++; 2129 sync_error++;
2129 } else { 2130 } else {
2130 int changed = remote_resource_is_changed(sn, dir, db, res, local_res); 2131 DavBool equal = FALSE;
2131 if(cdt && changed) { 2132 int changed = remote_resource_is_changed(sn, dir, db, res, local_res, &equal);
2133 if(equal) {
2134 if(local_res->metadata_updated) {
2135 ls_update = ucx_list_prepend(ls_update, local_res);
2136 }
2137 } else if(cdt && changed) {
2132 printf("conflict: %s\n", local_res->path); 2138 printf("conflict: %s\n", local_res->path);
2133 local_res->last_modified = 0; 2139 local_res->last_modified = 0;
2134 nullfree(local_res->etag); 2140 nullfree(local_res->etag);
2135 local_res->etag = NULL; 2141 local_res->etag = NULL;
2136 nullfree(local_res->hash); 2142 nullfree(local_res->hash);
2862 int remote_resource_is_changed( 2868 int remote_resource_is_changed(
2863 DavSession *sn, 2869 DavSession *sn,
2864 SyncDirectory *dir, 2870 SyncDirectory *dir,
2865 SyncDatabase *db, 2871 SyncDatabase *db,
2866 DavResource *remote, 2872 DavResource *remote,
2867 LocalResource *res) 2873 LocalResource *res,
2874 DavBool *equal)
2868 { 2875 {
2876 if(equal) {
2877 *equal = FALSE;
2878 }
2879
2869 DavPropName properties[] = { 2880 DavPropName properties[] = {
2870 {"DAV:", "getetag"}, 2881 {"DAV:", "getetag"},
2871 {DAV_NS, "version-collection"}, 2882 {DAV_NS, "version-collection"},
2872 {DAV_NS, "content-hash"}, 2883 {DAV_NS, "content-hash"},
2873 {DAV_NS, "split" }, 2884 {DAV_NS, "split" },
2886 2897
2887 int ret = 0; 2898 int ret = 0;
2888 if(err == 0) { 2899 if(err == 0) {
2889 char *etag = dav_get_string_property(remote, "D:getetag"); 2900 char *etag = dav_get_string_property(remote, "D:getetag");
2890 char *hash = sync_get_content_hash(remote); 2901 char *hash = sync_get_content_hash(remote);
2902
2903 if(hash && res->hash && equal) {
2904 // if requested, check if the local and remote are equal
2905 if(!strcmp(hash, res->hash)) {
2906 *equal = TRUE;
2907 return 0;
2908 }
2909 }
2910
2891 if(hash && res->prev_hash) { 2911 if(hash && res->prev_hash) {
2892 if(strcmp(hash, res->prev_hash)) { 2912 if(strcmp(hash, res->prev_hash)) {
2893 ret = 1; 2913 ret = 1;
2894 } 2914 }
2895 } else if(!res->etag) { 2915 } else if(!res->etag) {

mercurial