scanner: Clean up non-destructive rescan
Fix several issues with the non-destructive rescan functionality. Most of these issues also affected inotify scanning as well. These include annoying debug messages, adding album art for files that we aren't supposed to be scanning anyway, incrementing the UpdateID when no changes were made to the database, and other smaller issues.
This commit is contained in:
25
albumart.c
25
albumart.c
@ -104,6 +104,7 @@ update_if_album_art(const char *path)
|
||||
DIR *dh;
|
||||
struct dirent *dp;
|
||||
enum file_types type = TYPE_UNKNOWN;
|
||||
media_types dir_type;
|
||||
int64_t art_id = 0;
|
||||
int ret;
|
||||
|
||||
@ -122,6 +123,9 @@ update_if_album_art(const char *path)
|
||||
album_art = is_album_art(match);
|
||||
|
||||
strncpyt(dpath, path, sizeof(dpath));
|
||||
dir_type = valid_media_types(dpath);
|
||||
if (!(dir_type & (TYPE_VIDEO|TYPE_AUDIO)))
|
||||
return;
|
||||
dir = dirname(dpath);
|
||||
dh = opendir(dir);
|
||||
if( !dh )
|
||||
@ -129,29 +133,28 @@ update_if_album_art(const char *path)
|
||||
while ((dp = readdir(dh)) != NULL)
|
||||
{
|
||||
if (is_reg(dp) == 1)
|
||||
{
|
||||
type = TYPE_FILE;
|
||||
}
|
||||
else if (is_dir(dp) == 1)
|
||||
{
|
||||
type = TYPE_DIR;
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(file, sizeof(file), "%s/%s", dir, dp->d_name);
|
||||
type = resolve_unknown_type(file, ALL_MEDIA);
|
||||
type = resolve_unknown_type(file, dir_type);
|
||||
}
|
||||
if( type != TYPE_FILE )
|
||||
|
||||
if (type != TYPE_FILE || dp->d_name[0] == '.')
|
||||
continue;
|
||||
if( (dp->d_name[0] != '.') &&
|
||||
(is_video(dp->d_name) || is_audio(dp->d_name)) &&
|
||||
|
||||
if(((is_video(dp->d_name) && (dir_type & TYPE_VIDEO)) ||
|
||||
(is_audio(dp->d_name) && (dir_type & TYPE_AUDIO))) &&
|
||||
(album_art || strncmp(dp->d_name, match, ncmp) == 0) )
|
||||
{
|
||||
DPRINTF(E_DEBUG, L_METADATA, "New file %s looks like cover art for %s\n", path, dp->d_name);
|
||||
snprintf(file, sizeof(file), "%s/%s", dir, dp->d_name);
|
||||
art_id = find_album_art(file, NULL, 0);
|
||||
ret = sql_exec(db, "UPDATE DETAILS set ALBUM_ART = %lld where PATH = '%q'", (long long)art_id, file);
|
||||
if( ret != SQLITE_OK )
|
||||
ret = sql_exec(db, "UPDATE DETAILS set ALBUM_ART = %lld where PATH = '%q' and ALBUM_ART != %lld", (long long)art_id, file, (long long)art_id);
|
||||
if( ret == SQLITE_OK )
|
||||
DPRINTF(E_DEBUG, L_METADATA, "Updated cover art for %s to %s\n", dp->d_name, path);
|
||||
else
|
||||
DPRINTF(E_WARN, L_METADATA, "Error setting %s as cover art for %s\n", match, dp->d_name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user