Fix "prefer download" behavior

When this was first implemented the assumption was that a downloaded dive
that is to be merged with an existing dive would have the same time stamp.
But as Linus pointed out even back then, this does fail if a dive has been
merged with a download from a different dive computer before (think:
download from computer a, then download same dive from b, then improve
something in the parsing from computer a and try to redownload; the time
stamp could have changed).

This commit also fixes a silly omission in the merge_dives() function
(which ended up ALWAYS prefering the downloaded dive) and finally
implements the necessary changes to mark dives downloaded from a Uemis SDA
as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-11-21 15:34:04 -08:00
parent d872a5c8aa
commit 10ce60e212
5 changed files with 14 additions and 11 deletions

View file

@ -168,6 +168,7 @@ static struct {
} cur_event;
static struct tm cur_tm;
static int cur_cylinder_index, cur_ws_index;
static gboolean from_download;
static enum import_source {
UNKNOWN,
@ -1219,6 +1220,7 @@ static void dive_start(void)
add_dive_to_trip(cur_dive, cur_trip);
cur_dive->tripflag = IN_TRIP;
}
cur_dive->downloaded = from_download;
}
static void dive_end(void)
@ -1499,9 +1501,10 @@ static void reset_all(void)
import_source = UNKNOWN;
}
void parse_xml_buffer(const char *url, const char *buffer, int size, GError **error)
void parse_xml_buffer(const char *url, const char *buffer, int size, gboolean downloaded, GError **error)
{
xmlDoc *doc;
from_download = downloaded;
doc = xmlReadMemory(buffer, size, url, NULL, 0);
if (!doc) {