From 755b52febc1f0e6bcbb08da90abc4915ac1be905 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 20 Feb 2018 20:03:21 +0100 Subject: [PATCH] Improve the fingerprint matching Check the fingerprint before downloading the dive. If a match is found, this avoids some unnecessary communication and thus makes the download a little bit faster. --- src/suunto_eonsteel.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/suunto_eonsteel.c b/src/suunto_eonsteel.c index 0cf63c9..2e2e8fd 100644 --- a/src/suunto_eonsteel.c +++ b/src/suunto_eonsteel.c @@ -717,15 +717,23 @@ suunto_eonsteel_device_foreach(dc_device_t *abstract, dc_dive_callback_t callbac case DIRTYPE_FILE: if (skip) break; + if (sscanf(de->name, "%x.LOG", &time) != 1) break; + + put_le32(time, buf); + + if (memcmp (buf, eon->fingerprint, sizeof (eon->fingerprint)) == 0) { + skip = 1; + break; + } + len = snprintf(pathname, sizeof(pathname), "%s/%s", dive_directory, de->name); if (len >= sizeof(pathname)) break; // Reset the membuffer, put the 4-byte length at the head. dc_buffer_clear(file); - put_le32(time, buf); dc_buffer_append(file, buf, 4); // Then read the filename into the rest of the buffer @@ -736,11 +744,6 @@ suunto_eonsteel_device_foreach(dc_device_t *abstract, dc_dive_callback_t callbac data = dc_buffer_get_data(file); size = dc_buffer_get_size(file); - if (memcmp (data, eon->fingerprint, sizeof (eon->fingerprint)) == 0) { - skip = 1; - break; - } - if (callback && !callback(data, size, data, sizeof(eon->fingerprint), userdata)) skip = 1; }