diff options
author | glerch <guido.lerch@gmail.com> | 2015-09-10 19:05:29 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-10 12:33:22 -0700 |
commit | 6504d97ca81d1e2b763ab1d7d41b13448c48c754 (patch) | |
tree | 8ae49796f5d5faab2b233753e39b6f1f64aecc6d /uemis-downloader.c | |
parent | 1aa941e754db29bec61523056366db271861de9b (diff) | |
download | subsurface-6504d97ca81d1e2b763ab1d7d41b13448c48c754.tar.gz |
Uemis downloader: assure empty divespots are not added
If the load_uemis_divespot returns false we must assure
we delete the divespot that was created during process_raw_buffer
Also added some comments
Signed-off-by: glerch <guido.lerch@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'uemis-downloader.c')
-rw-r--r-- | uemis-downloader.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c index f1f17828d..1472d428a 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -1191,17 +1191,30 @@ const char *do_uemis_import(device_data_t *data) last_found_log_file_nr = dive_to_read; int divespot_id = uemis_get_divespot_id_by_diveid(dive->dc.diveid); if (load_uemis_divespot(mountpath, divespot_id)) { + /* get the divesite based on the diveid, this should give us + * the newly created site + */ struct dive_site *nds = get_dive_site_by_uuid(dive->dive_site_uuid); struct dive_site *ods = NULL; if (nds) { + /* with the divesite name we got from parse_dive, that is called on load_uemis_divespot + * we search all existing divesites if we have one with the same name already. The function + * returns the first found which is luckily not the newly created. + */ (void)get_dive_site_uuid_by_name(nds->name, &ods); if (ods) { + /* if the uuid's are the same, the new site is a duplicat and can be deleted */ if (nds->uuid != ods->uuid) { delete_dive_site(nds->uuid); dive->dive_site_uuid = ods->uuid; } } } + } else { + /* if we cant load the dive site details, delete the site we + * created in process_raw_buffer + */ + delete_dive_site(dive->dive_site_uuid); } } else { /* in this case we found a deleted file, so let's increment */ |