mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Uemis downloader: download additional dive data after every batch
This looks like a fairly big change but it mostly just moves a block of code inside an earlier loop and adjust a few variables around it. The completely broken and insane Uemis download protocol distributes data across different "databases" on the dive computer. The "divelogs" are downloaded in batches of 10 (most of the time), and with this change every time one of those batches is downloaded we straight away get the matching "dive" entries. Hopefully this will avoid having the download abort (for lack of space) before all components are loaded. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7101386cb6
commit
df9f233eed
1 changed files with 44 additions and 40 deletions
|
@ -849,7 +849,8 @@ const char *do_uemis_import(device_data_t *data)
|
||||||
const char *mountpath = data->devname;
|
const char *mountpath = data->devname;
|
||||||
short force_download = data->force_download;
|
short force_download = data->force_download;
|
||||||
char *newmax = NULL;
|
char *newmax = NULL;
|
||||||
int start, end = -2, i, offset;
|
int first, start, end = -2;
|
||||||
|
int i, offset = 0;
|
||||||
uint32_t deviceidnr;
|
uint32_t deviceidnr;
|
||||||
char objectid[10];
|
char objectid[10];
|
||||||
char *deviceid = NULL;
|
char *deviceid = NULL;
|
||||||
|
@ -887,7 +888,7 @@ const char *do_uemis_import(device_data_t *data)
|
||||||
newmax = uemis_get_divenr(deviceid);
|
newmax = uemis_get_divenr(deviceid);
|
||||||
else
|
else
|
||||||
newmax = strdup("0");
|
newmax = strdup("0");
|
||||||
start = atoi(newmax);
|
first = start = atoi(newmax);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
#if UEMIS_DEBUG & 4
|
#if UEMIS_DEBUG & 4
|
||||||
fprintf(debugfile, "d_u_i inner loop start %d end %d newmax %s\n", start, end, newmax);
|
fprintf(debugfile, "d_u_i inner loop start %d end %d newmax %s\n", start, end, newmax);
|
||||||
|
@ -919,25 +920,9 @@ const char *do_uemis_import(device_data_t *data)
|
||||||
#if UEMIS_DEBUG & 4
|
#if UEMIS_DEBUG & 4
|
||||||
fprintf(debugfile, "d_u_i after download and parse start %d end %d newmax %s progress %4.2f\n", start, end, newmax, progress_bar_fraction);
|
fprintf(debugfile, "d_u_i after download and parse start %d end %d newmax %s progress %4.2f\n", start, end, newmax, progress_bar_fraction);
|
||||||
#endif
|
#endif
|
||||||
/* if the user clicked cancel, exit gracefully */
|
/* now download the additional dive data with "getDive" for the dives
|
||||||
if (import_thread_cancelled)
|
* we just downloaded - yes, this is completely insane - why isn't all of
|
||||||
goto bail;
|
* this downloaded in the first place??? */
|
||||||
/* if we got an error or got nothing back, stop trying */
|
|
||||||
if (!success || !param_buff[3])
|
|
||||||
break;
|
|
||||||
/* finally, if the memory is getting too full, maybe we better stop, too */
|
|
||||||
if (progress_bar_fraction > 0.85) {
|
|
||||||
result = translate("gettextFromC", ERR_FS_ALMOST_FULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (end == -2 && sscanf(newmax, "%d", &end) != 1)
|
|
||||||
end = start;
|
|
||||||
#if UEMIS_DEBUG & 2
|
|
||||||
fprintf(debugfile, "done: read from object_id %d to %d\n", start, end);
|
|
||||||
#endif
|
|
||||||
free(newmax);
|
|
||||||
offset = 0;
|
|
||||||
for (i = start; i <= end; i++) {
|
for (i = start; i <= end; i++) {
|
||||||
snprintf(objectid, sizeof(objectid), "%d", i + offset);
|
snprintf(objectid, sizeof(objectid), "%d", i + offset);
|
||||||
param_buff[2] = objectid;
|
param_buff[2] = objectid;
|
||||||
|
@ -974,6 +959,25 @@ const char *do_uemis_import(device_data_t *data)
|
||||||
if (!success || import_thread_cancelled)
|
if (!success || import_thread_cancelled)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
start = end + 1;
|
||||||
|
/* if the user clicked cancel, exit gracefully */
|
||||||
|
if (import_thread_cancelled)
|
||||||
|
goto bail;
|
||||||
|
/* if we got an error or got nothing back, stop trying */
|
||||||
|
if (!success || !param_buff[3])
|
||||||
|
break;
|
||||||
|
/* finally, if the memory is getting too full, maybe we better stop, too */
|
||||||
|
if (progress_bar_fraction > 0.85) {
|
||||||
|
result = translate("gettextFromC", ERR_FS_ALMOST_FULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (end == -2 && sscanf(newmax, "%d", &end) != 1)
|
||||||
|
end = start;
|
||||||
|
#if UEMIS_DEBUG & 2
|
||||||
|
fprintf(debugfile, "done: read from object_id %d to %d\n", first, end);
|
||||||
|
#endif
|
||||||
|
free(newmax);
|
||||||
success = true;
|
success = true;
|
||||||
for (i = 0; i <= nr_divespots; i++) {
|
for (i = 0; i <= nr_divespots; i++) {
|
||||||
char divespotnr[10];
|
char divespotnr[10];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue