Wed, 10 Apr 2019 11:03:37 +0200
store origin of file conflicts
dav/db.c | file | annotate | diff | comparison | revisions | |
dav/db.h | file | annotate | diff | comparison | revisions | |
dav/sync.c | file | annotate | diff | comparison | revisions | |
libidav/webdav.h | file | annotate | diff | comparison | revisions |
--- 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); + } + // </conflict> xmlTextWriterEndElement(writer); }
--- 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 {
--- 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); } }