mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-23 02:57:45 -05:00
[db] Move calculation of artist/album id's from sqlite to code
The purpose of this is to support library backends making their own calculation of these id's, which is relevant if they have more information available than just album_artist and album. This also removes a bunch of sqlite extension code plus some triggers, which in itself is probably an improvement.
This commit is contained in:
23
src/misc.c
23
src/misc.c
@@ -747,6 +747,29 @@ djb_hash(const void *data, size_t len)
|
||||
return hash;
|
||||
}
|
||||
|
||||
int64_t
|
||||
two_str_hash(const char *a, const char *b)
|
||||
{
|
||||
char hashbuf[2048];
|
||||
int64_t hash;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
ret = snprintf(hashbuf, sizeof(hashbuf), "%s==%s", (a) ? a : "", (b) ? b : "");
|
||||
if (ret < 0 || ret == sizeof(hashbuf))
|
||||
{
|
||||
DPRINTF(E_LOG, L_MISC, "Buffer too large to calculate hash: '%s==%s'\n", a, b);
|
||||
return 999999; // Stand-in hash...
|
||||
}
|
||||
|
||||
for (i = 0; hashbuf[i]; i++)
|
||||
hashbuf[i] = tolower(hashbuf[i]);
|
||||
|
||||
// Limit hash length to 63 bits, due to signed type in sqlite
|
||||
hash = murmur_hash64(hashbuf, strlen(hashbuf), 0) >> 1;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static unsigned char b64_decode_table[256];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user