Do not save dive sites that are not used

As it is not possible to delete dive sites from the logbook, we
need to make sure that we never save sites that are not tied to
any dive. With this change, unused site that are currently in
the logbook will also be removed, so it will also clear up
(wrong) historical data.

Supposed to fix #786

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
Jan Mulder 2017-11-08 12:22:48 +01:00 committed by Lubomir I. Ivanov
parent 20510d4ff7
commit 8d0361ff77
2 changed files with 2 additions and 2 deletions

View file

@ -904,7 +904,7 @@ static void save_divesites(git_repository *repo, struct dir *tree)
for (int i = 0; i < dive_site_table.nr; i++) { for (int i = 0; i < dive_site_table.nr; i++) {
struct membuffer b = { 0 }; struct membuffer b = { 0 };
struct dive_site *ds = get_dive_site(i); struct dive_site *ds = get_dive_site(i);
if (dive_site_is_empty(ds)) { if (dive_site_is_empty(ds) || !is_dive_site_used(ds->uuid, false)) {
int j; int j;
struct dive *d; struct dive *d;
for_each_dive(j, d) { for_each_dive(j, d) {

View file

@ -571,7 +571,7 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
int j; int j;
struct dive *d; struct dive *d;
struct dive_site *ds = get_dive_site(i); struct dive_site *ds = get_dive_site(i);
if (dive_site_is_empty(ds)) { if (dive_site_is_empty(ds) || !is_dive_site_used(ds->uuid, false)) {
for_each_dive(j, d) { for_each_dive(j, d) {
if (d->dive_site_uuid == ds->uuid) if (d->dive_site_uuid == ds->uuid)
d->dive_site_uuid = 0; d->dive_site_uuid = 0;