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
|
@ -66,6 +66,7 @@ struct cache_command
|
|||
int format;
|
||||
time_t mtime;
|
||||
int cached;
|
||||
int del;
|
||||
|
||||
struct evbuffer *evbuf;
|
||||
} arg;
|
||||
|
@ -943,6 +944,8 @@ cache_artwork_ping_impl(struct cache_command *cmd)
|
|||
|
||||
sqlite3_free(query);
|
||||
|
||||
if (cmd->arg.del > 0)
|
||||
{
|
||||
query = sqlite3_mprintf(Q_TMPL_DEL, cmd->arg.path, (int64_t)cmd->arg.mtime);
|
||||
|
||||
DPRINTF(E_DBG, L_CACHE, "Running query '%s'\n", query);
|
||||
|
@ -958,6 +961,7 @@ cache_artwork_ping_impl(struct cache_command *cmd)
|
|||
}
|
||||
|
||||
sqlite3_free(query);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -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