summaryrefslogtreecommitdiffstats
path: root/subsurface-core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-09 17:57:02 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-09 17:57:02 -0800
commit779a70629bc883f62321dc195a6c931f6d52f1c9 (patch)
tree42de15863c0f71a7c9a6c5660b8687990c3d20d7 /subsurface-core
parent2075038de1d3a181eb964020c635099ebf52b4ed (diff)
downloadsubsurface-779a70629bc883f62321dc195a6c931f6d52f1c9.tar.gz
Uemis downloader: deal with a whole block of deleted dives
If every dive in a download block from the Uemis was deleted we kept downloading that same block of dives. With this we remember how far we got even if the dives ended up being deleted. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core')
-rw-r--r--subsurface-core/uemis-downloader.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/subsurface-core/uemis-downloader.c b/subsurface-core/uemis-downloader.c
index cb59df6d7..2d837f0cb 100644
--- a/subsurface-core/uemis-downloader.c
+++ b/subsurface-core/uemis-downloader.c
@@ -73,6 +73,8 @@ static int max_mem_used = -1;
static int next_table_index = 0;
static int dive_to_read = 0;
+static int max_deleted_seen = -1;
+
/* helper function to parse the Uemis data structures */
static void uemis_ts(char *buffer, void *_when)
{
@@ -971,6 +973,12 @@ static char *uemis_get_divenr(char *deviceidstr, int force)
maxdiveid = dc->diveid;
}
}
+ if (max_deleted_seen >= 0 && maxdiveid < max_deleted_seen) {
+ maxdiveid = max_deleted_seen;
+#if UEMIS_DEBUG & 4
+ fprintf(debugfile, "overriding max seen with max deleted seen %d\n", max_deleted_seen);
+#endif
+ }
snprintf(divenr, 10, "%d", maxdiveid);
return strdup(divenr);
}
@@ -1156,10 +1164,11 @@ static bool get_matching_dive(int idx, char *newmax, int *uemis_mem_status, stru
fprintf(debugfile, "TRY matching divelog id %d from %s with dive details %d but details are deleted\n", dive->dc.diveid, d_time, dive_to_read);
#endif
deleted_files++;
+ max_deleted_seen = dive_to_read;
/* mark this log entry as deleted and cleanup later, otherwise we mess up our array */
dive->downloaded = false;
#if UEMIS_DEBUG & 2
- fprintf(debugfile, "Deleted dive from %s, with id %d from table\n", d_time, dive->dc.diveid);
+ fprintf(debugfile, "Deleted dive from %s, with id %d from table -- newmax is %s\n", d_time, dive->dc.diveid, newmax);
#endif
}
} else {