diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-09-22 14:17:24 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-09-22 14:17:24 -0700 |
commit | d2b8088cd8cc41e473175b748b6aa164c4812766 (patch) | |
tree | e73ab36b3f48cf435b3eec03639e5dac6183bc56 | |
parent | 1a7d9881af8fb36f4dc5c877d1ac0685b7b56032 (diff) | |
download | subsurface-d2b8088cd8cc41e473175b748b6aa164c4812766.tar.gz |
Actually create a UUID when creating a dive site during download
The existing code creates a deterministic ID (not exactly "unique") in order to
help us avoid merge conflicts in git-storage mode. But as a side effect, if we
re-download the same dive twice from a dive computer that supports GPS (right
now only the Garmin Descent Mk1) we are guaranteed to create the same dive site
uuid when we do this. So when we download a dive - whether we will actually
*use* that dive later or not - we will be filling in the dive site information
with the data we got from the dive computer.
... and in the process we will be overwriting any data that was filled in
manually. The name of the dive site, but also possibly even the GPS of the dive
site (maybe the user decided to edit that using the map, because while the
automatically downloaded GPS data was "correct", maybe the user wanted to
change it to be the actual under-water location using the satellite data,
rather than the place where you started the dive or where you surfaced).
In order to avoid this collision, this patch just makes the libdivecomputer
download not use the dive time, but "time of download" for the dive site time,
and thus effectively generate a new uuid for every download.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/libdivecomputer.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index 2b535dfaf..fcc774425 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -12,6 +12,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <time.h> #include "gettext.h" #include "dive.h" #include "subsurface-string.h" @@ -615,7 +616,7 @@ static void parse_string_field(struct dive *dive, dc_field_string_t *str) longitude = parse_degrees(line, &line); if (latitude.udeg && longitude.udeg) - dive->dive_site_uuid = create_dive_site_with_gps(str->value, latitude, longitude, dive->when); + dive->dive_site_uuid = create_dive_site_with_gps(str->value, latitude, longitude, time(NULL)); } } #endif |