mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 15:15:57 -05:00
Merge pull request #135 from chme/bulkscan
do not execute individual delete queries for cached artwork files during bulk scan
This commit is contained in:
commit
a98f67a7b3
31
src/cache.c
31
src/cache.c
@ -66,6 +66,7 @@ struct cache_command
|
||||
int format;
|
||||
time_t mtime;
|
||||
int cached;
|
||||
int del;
|
||||
|
||||
struct evbuffer *evbuf;
|
||||
} arg;
|
||||
@ -943,22 +944,25 @@ cache_artwork_ping_impl(struct cache_command *cmd)
|
||||
|
||||
sqlite3_free(query);
|
||||
|
||||
query = sqlite3_mprintf(Q_TMPL_DEL, cmd->arg.path, (int64_t)cmd->arg.mtime);
|
||||
|
||||
DPRINTF(E_DBG, L_CACHE, "Running query '%s'\n", query);
|
||||
|
||||
ret = sqlite3_exec(g_db_hdl, query, NULL, NULL, &errmsg);
|
||||
if (ret != SQLITE_OK)
|
||||
if (cmd->arg.del > 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_CACHE, "Query error: %s\n", errmsg);
|
||||
query = sqlite3_mprintf(Q_TMPL_DEL, cmd->arg.path, (int64_t)cmd->arg.mtime);
|
||||
|
||||
DPRINTF(E_DBG, L_CACHE, "Running query '%s'\n", query);
|
||||
|
||||
ret = sqlite3_exec(g_db_hdl, query, NULL, NULL, &errmsg);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
DPRINTF(E_LOG, L_CACHE, "Query error: %s\n", errmsg);
|
||||
|
||||
sqlite3_free(errmsg);
|
||||
sqlite3_free(query);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sqlite3_free(errmsg);
|
||||
sqlite3_free(query);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sqlite3_free(query);
|
||||
|
||||
return 0;
|
||||
|
||||
#undef Q_TMPL_PING
|
||||
@ -1235,7 +1239,7 @@ cache_artwork_read_impl(struct cache_command *cmd)
|
||||
|
||||
cmd->arg.format = g_stash.format;
|
||||
|
||||
DPRINTF(E_DBG, L_CACHE, "Stash hit (format %d, size %d): %s\n", g_stash.format, g_stash.size, g_stash.path);
|
||||
DPRINTF(E_DBG, L_CACHE, "Stash hit (format %d, size %zu): %s\n", g_stash.format, g_stash.size, g_stash.path);
|
||||
|
||||
return evbuffer_add(cmd->arg.evbuf, g_stash.data, g_stash.size);
|
||||
}
|
||||
@ -1437,7 +1441,7 @@ cache_daap_threshold(void)
|
||||
* @return 0 if successful, -1 if an error occurred
|
||||
*/
|
||||
int
|
||||
cache_artwork_ping(char *path, time_t mtime)
|
||||
cache_artwork_ping(char *path, time_t mtime, int del)
|
||||
{
|
||||
struct cache_command cmd;
|
||||
int ret;
|
||||
@ -1450,6 +1454,7 @@ cache_artwork_ping(char *path, time_t mtime)
|
||||
cmd.func = cache_artwork_ping_impl;
|
||||
cmd.arg.path = strdup(path);
|
||||
cmd.arg.mtime = mtime;
|
||||
cmd.arg.del = del;
|
||||
|
||||
ret = sync_command(&cmd);
|
||||
|
||||
|
@ -31,7 +31,7 @@ cache_daap_threshold(void);
|
||||
#define CACHE_ARTWORK_INDIVIDUAL 1
|
||||
|
||||
int
|
||||
cache_artwork_ping(char *path, time_t mtime);
|
||||
cache_artwork_ping(char *path, time_t mtime, int del);
|
||||
|
||||
int
|
||||
cache_artwork_delete_by_path(char *path);
|
||||
|
@ -844,12 +844,16 @@ process_deferred_playlists(void)
|
||||
static void
|
||||
process_file(char *file, time_t mtime, off_t size, int type, int flags)
|
||||
{
|
||||
int is_bulkscan;
|
||||
|
||||
is_bulkscan = (flags & F_SCAN_BULK);
|
||||
|
||||
switch (file_type_get(file))
|
||||
{
|
||||
case FILE_REGULAR:
|
||||
filescanner_process_media(file, mtime, size, type, NULL);
|
||||
|
||||
cache_artwork_ping(file, mtime);
|
||||
cache_artwork_ping(file, mtime, !is_bulkscan);
|
||||
// TODO [artworkcache] If entry in artwork cache exists for no artwork available, delete the entry if media file has embedded artwork
|
||||
|
||||
counter++;
|
||||
@ -878,7 +882,7 @@ process_file(char *file, time_t mtime, off_t size, int type, int flags)
|
||||
|
||||
case FILE_ARTWORK:
|
||||
DPRINTF(E_DBG, L_SCAN, "Artwork file: %s\n", file);
|
||||
cache_artwork_ping(file, mtime);
|
||||
cache_artwork_ping(file, mtime, !is_bulkscan);
|
||||
|
||||
// TODO [artworkcache] If entry in artwork cache exists for no artwork available for a album with files in the same directory, delete the entry
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user