summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--save-git.c16
-rw-r--r--save-xml.c15
2 files changed, 29 insertions, 2 deletions
diff --git a/save-git.c b/save-git.c
index 9aa7bfd0e..69ad0726d 100644
--- a/save-git.c
+++ b/save-git.c
@@ -892,9 +892,23 @@ static void save_divesites(git_repository *repo, struct dir *tree)
if (d->dive_site_uuid == ds->uuid)
d->dive_site_uuid = 0;
}
- delete_dive_site(get_dive_site(i)->uuid);
+ delete_dive_site(ds->uuid);
i--; // since we just deleted that one
continue;
+ } else if (ds->name &&
+ (strncmp(ds->name, "Auto-created dive", 17) == 0 ||
+ strncmp(ds->name, "New Dive", 8) == 0)) {
+ fprintf(stderr, "found an auto divesite %s\n", ds->name);
+ // these are the two default names for sites from
+ // the web service; if the site isn't used in any
+ // dive (really? you didn't rename it?), delete it
+ if (!is_dive_site_used(ds->uuid, false)) {
+ if (verbose)
+ fprintf(stderr, "Deleted unused auto-created dive site %s\n", ds->name);
+ delete_dive_site(ds->uuid);
+ i--; // since we just deleted that one
+ continue;
+ }
}
struct membuffer site_file_name = { 0 };
put_format(&site_file_name, "Site-%08x", ds->uuid);
diff --git a/save-xml.c b/save-xml.c
index 6921e3b2e..6d0284056 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -523,9 +523,22 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
if (d->dive_site_uuid == ds->uuid)
d->dive_site_uuid = 0;
}
- delete_dive_site(get_dive_site(i)->uuid);
+ delete_dive_site(ds->uuid);
i--; // since we just deleted that one
continue;
+ } else if (ds->name &&
+ (strncmp(ds->name, "Auto-created dive", 17) == 0 ||
+ strncmp(ds->name, "New Dive", 8) == 0)) {
+ // these are the two default names for sites from
+ // the web service; if the site isn't used in any
+ // dive (really? you didn't rename it?), delete it
+ if (!is_dive_site_used(ds->uuid, false)) {
+ if (verbose)
+ fprintf(stderr, "Deleted unused auto-created dive site %s\n", ds->name);
+ delete_dive_site(ds->uuid);
+ i--; // since we just deleted that one
+ continue;
+ }
}
if (select_only && !is_dive_site_used(ds->uuid, true))
continue;