# HG changeset patch # User Olaf Wintermann # Date 1554887017 -7200 # Node ID a816e805e5db9527afdbc4d98d8968df8ae2ecae # Parent ba54fc8abdf158bdec879e9059d08e08a94acbfc store origin of file conflicts diff -r ba54fc8abdf1 -r a816e805e5db dav/db.c --- a/dav/db.c Tue Apr 09 18:23:23 2019 +0200 +++ b/dav/db.c Wed Apr 10 11:03:37 2019 +0200 @@ -329,23 +329,34 @@ LocalResource* process_conflict(xmlTextReaderPtr reader) { LocalResource *res = calloc(1, sizeof(LocalResource)); - int path = 0; + int field = 0; while(xmlTextReaderRead(reader)) { int type = xmlTextReaderNodeType(reader); const xmlChar *name = xmlTextReaderConstName(reader); if(type == XML_READER_TYPE_ELEMENT) { if(xstreq(name, "path")) { - path = 1; + field = 1; + } else if(xstreq(name, "source")) { + field = 2; } - } else if(type == XML_READER_TYPE_TEXT && path) { + } else if(type == XML_READER_TYPE_TEXT) { const xmlChar *value = xmlTextReaderConstValue(reader); - res->path = strdup((char*)value); + switch(field) { + case 1: { + res->path = strdup((const char*)value); + break; + } + case 2: { + res->conflict_source = strdup((const char*)value); + break; + } + } } else if(XML_READER_TYPE_END_ELEMENT) { if(xstreq(name, "conflict")) { break; } else { - path = 0; + field = 0; } } } @@ -609,6 +620,13 @@ BAD_CAST "path", BAD_CAST res->path); + if(res->conflict_source) { + xmlTextWriterWriteElement( + writer, + BAD_CAST "source", + BAD_CAST res->conflict_source); + } + // xmlTextWriterEndElement(writer); } diff -r ba54fc8abdf1 -r a816e805e5db dav/db.h --- a/dav/db.h Tue Apr 09 18:23:23 2019 +0200 +++ b/dav/db.h Wed Apr 10 11:03:37 2019 +0200 @@ -83,6 +83,7 @@ DavBool isnew; LocalResource *origin; + char *conflict_source; }; struct FilePart { diff -r ba54fc8abdf1 -r a816e805e5db dav/sync.c --- a/dav/sync.c Tue Apr 09 18:23:23 2019 +0200 +++ b/dav/sync.c Wed Apr 10 11:03:37 2019 +0200 @@ -867,8 +867,8 @@ DavBool nochange = FALSE; char *content_hash = sync_get_content_hash(res); - if(content_hash || local->hash) { - if(!nullstrcmp(content_hash, local->hash)) { + if(content_hash && local->hash) { + if(!strcmp(content_hash, local->hash)) { nochange = TRUE; } } else if(local->etag) { @@ -1141,8 +1141,9 @@ } fclose(out); - if(issplit) { + if(issplit || dir->hashing) { if(truncate_file >= 0) { + // only true if issplit is true if(truncate(local_path, truncate_file)) { perror("truncate"); } @@ -1325,6 +1326,7 @@ } else { LocalResource *conflict = calloc(1, sizeof(LocalResource)); conflict->path = strdup(new_res_path.ptr); + conflict->conflict_source = strdup(path); ucx_map_cstr_put(db->conflict, new_res_path.ptr, conflict); } } diff -r ba54fc8abdf1 -r a816e805e5db libidav/webdav.h --- a/libidav/webdav.h Tue Apr 09 18:23:23 2019 +0200 +++ b/libidav/webdav.h Wed Apr 10 11:03:37 2019 +0200 @@ -41,7 +41,7 @@ extern "C" { #endif -typedef int DavBool; +typedef char DavBool; #ifndef TRUE #define TRUE 1 #endif