From 8d0361ff77707b9cae7c6bea6109c776afd6e2a6 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Wed, 8 Nov 2017 12:22:48 +0100 Subject: 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 --- core/save-git.c | 2 +- core/save-xml.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/save-git.c b/core/save-git.c index 5ff67ddea..6496d28ad 100644 --- a/core/save-git.c +++ b/core/save-git.c @@ -904,7 +904,7 @@ static void save_divesites(git_repository *repo, struct dir *tree) for (int i = 0; i < dive_site_table.nr; i++) { struct membuffer b = { 0 }; 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; struct dive *d; for_each_dive(j, d) { diff --git a/core/save-xml.c b/core/save-xml.c index d3b9e6c8d..5bc4f5b38 100644 --- a/core/save-xml.c +++ b/core/save-xml.c @@ -571,7 +571,7 @@ void save_dives_buffer(struct membuffer *b, const bool select_only) int j; struct dive *d; 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) { if (d->dive_site_uuid == ds->uuid) d->dive_site_uuid = 0; -- cgit v1.2.3-70-g09d2