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.
This commit is contained in:
Jef Driesen 2018-02-20 20:03:21 +01:00
parent 01ccb7ce4b
commit 755b52febc

View File

@ -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;
}