mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
core: use fingerprint table and on disk fingerprints
In order to not break existing behavior, we still store fingerprints on disk, but we first check the data in the in-memory table, and we remember the fingerprint data in the fingerprint table as well (which is then saved as part of the dive log data). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fa250906c9
commit
02c770d997
1 changed files with 17 additions and 0 deletions
|
@ -967,10 +967,20 @@ static void lookup_fingerprint(dc_device_t *device, device_data_t *devdata)
|
||||||
{
|
{
|
||||||
char *cachename;
|
char *cachename;
|
||||||
struct memblock mem;
|
struct memblock mem;
|
||||||
|
const unsigned char *raw_data;
|
||||||
|
|
||||||
if (devdata->force_download)
|
if (devdata->force_download)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* first try our in memory data - raw_data is owned by the table, the dc_device_set_fingerprint function copies the data */
|
||||||
|
int fsize = get_fingerprint_data(&fingerprint_table, calculate_string_hash(devdata->model), devdata->devinfo.serial, &raw_data);
|
||||||
|
if (fsize) {
|
||||||
|
if (verbose)
|
||||||
|
dev_info(devdata, "... found fingerprint in dive table");
|
||||||
|
dc_device_set_fingerprint(device, raw_data, fsize);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* now check if we have a fingerprint on disk */
|
||||||
cachename = fingerprint_file(devdata);
|
cachename = fingerprint_file(devdata);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
dev_info(devdata, "Looking for fingerprint in '%s'", cachename);
|
dev_info(devdata, "Looking for fingerprint in '%s'", cachename);
|
||||||
|
@ -1447,8 +1457,15 @@ const char *do_libdivecomputer_import(device_data_t *data)
|
||||||
* we got a dive header, and because we will use the
|
* we got a dive header, and because we will use the
|
||||||
* dive id to verify that we actually have the dive
|
* dive id to verify that we actually have the dive
|
||||||
* it refers to before we use the fingerprint data.
|
* it refers to before we use the fingerprint data.
|
||||||
|
*
|
||||||
|
* For now we save the fingerprint both to the local file system
|
||||||
|
* and to the global fingerprint table (to be then saved out with
|
||||||
|
* the dive log data).
|
||||||
*/
|
*/
|
||||||
save_fingerprint(data);
|
save_fingerprint(data);
|
||||||
|
if (data->fingerprint && data->fdiveid)
|
||||||
|
create_fingerprint_node(&fingerprint_table, calculate_string_hash(data->model), data->devinfo.serial,
|
||||||
|
data->fingerprint, data->fsize, data->fdeviceid, data->fdiveid);
|
||||||
free(data->fingerprint);
|
free(data->fingerprint);
|
||||||
data->fingerprint = NULL;
|
data->fingerprint = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue