summaryrefslogtreecommitdiffstats
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-12-06 09:27:36 -0800
commit31cdc9320eeb8c668bf2cdf15f2f8f6b7fc11603 (patch)
tree7e453b258821bf510d955c19d459627ba0d72142
parent6b9d4669d181161f42cf10f76c2ff5a2b921c997 (diff)
downloadsubsurface-31cdc9320eeb8c668bf2cdf15f2f8f6b7fc11603.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>
-rw-r--r--uemis-downloader.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c
index cb59df6d7..2d837f0cb 100644
--- a/uemis-downloader.c
+++ b/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 {