523 } |
523 } |
524 // set metadata from stat |
524 // set metadata from stat |
525 local->etag = strdup(etag); |
525 local->etag = strdup(etag); |
526 local->last_modified = s.st_mtime; |
526 local->last_modified = s.st_mtime; |
527 local->size = s.st_size; |
527 local->size = s.st_size; |
|
528 local->skipped = FALSE; |
528 } else { |
529 } else { |
529 if(unlink(tmp_path)) { |
530 if(unlink(tmp_path)) { |
530 fprintf(stderr, "Cannot remove tmp file: %s\n", tmp_path); |
531 fprintf(stderr, "Cannot remove tmp file: %s\n", tmp_path); |
531 } |
532 } |
532 } |
533 } |
805 error = 1; |
806 error = 1; |
806 } |
807 } |
807 } else { |
808 } else { |
808 if(cdt && remote_resource_is_changed(sn, dir, db, local_res)) { |
809 if(cdt && remote_resource_is_changed(sn, dir, db, local_res)) { |
809 printf("conflict: %s\n", local_res->path); |
810 printf("conflict: %s\n", local_res->path); |
|
811 local_res->last_modified = 0; |
|
812 local_res->skipped = TRUE; |
810 sync_skipped++; |
813 sync_skipped++; |
811 continue; |
814 } else { |
812 } |
815 printf("put: %s\n", local_res->path); |
813 |
816 if(sync_put_resource(dir, res, local_res, &sync_success)) { |
814 printf("put: %s\n", local_res->path); |
817 sync_error++; |
815 if(sync_put_resource(dir, res, local_res, &sync_success)) { |
818 print_resource_error(sn, res->path); |
816 sync_error++; |
819 ret = -1; |
817 print_resource_error(sn, res->path); |
820 error = 1; |
818 ret = -1; |
821 } |
819 error = 1; |
|
820 } |
822 } |
821 } |
823 } |
822 dav_resource_free(res); |
824 dav_resource_free(res); |
823 } |
825 } |
824 |
826 |
1256 } |
1258 } |
1257 |
1259 |
1258 free(dc); |
1260 free(dc); |
1259 } |
1261 } |
1260 |
1262 |
|
1263 static void resolve_skipped(SyncDatabase *db) { |
|
1264 UcxKey k; |
|
1265 LocalResource *res; |
|
1266 UcxMapIterator i = ucx_map_iterator(db->resources); |
|
1267 int skipped = 0; |
|
1268 UCX_MAP_FOREACH(k, res, i) { |
|
1269 if(res->skipped) { |
|
1270 skipped++; |
|
1271 fprintf(stderr, "skipped from push: %s\n", res->path); |
|
1272 } |
|
1273 } |
|
1274 if(skipped > 0) { |
|
1275 fprintf(stderr, |
|
1276 " To resolve conflict resources skipped by push run dav-sync pull first\n" |
|
1277 " before resolve-conflicts or delete-conflicts.\n\n"); |
|
1278 } |
|
1279 } |
|
1280 |
1261 int cmd_resolve_conflicts(CmdArgs *a) { |
1281 int cmd_resolve_conflicts(CmdArgs *a) { |
1262 if(a->argc != 1) { |
1282 if(a->argc != 1) { |
1263 fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many"); |
1283 fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many"); |
1264 return -1; |
1284 return -1; |
1265 } |
1285 } |