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:
64
utils.c
64
utils.c
@ -435,6 +435,27 @@ is_caption(const char * file)
|
||||
return (ends_with(file, ".srt") || ends_with(file, ".smi"));
|
||||
}
|
||||
|
||||
media_types
|
||||
get_media_type(const char *file)
|
||||
{
|
||||
const char *ext = strrchr(file, '.');
|
||||
if (!ext)
|
||||
return NO_MEDIA;
|
||||
if (is_image(ext))
|
||||
return TYPE_IMAGE;
|
||||
if (is_video(ext))
|
||||
return TYPE_VIDEO;
|
||||
if (is_audio(ext))
|
||||
return TYPE_AUDIO;
|
||||
if (is_playlist(ext))
|
||||
return TYPE_PLAYLIST;
|
||||
if (is_caption(ext))
|
||||
return TYPE_CAPTION;
|
||||
if (is_nfo(ext))
|
||||
return TYPE_NFO;
|
||||
return NO_MEDIA;
|
||||
}
|
||||
|
||||
int
|
||||
is_album_art(const char * name)
|
||||
{
|
||||
@ -462,7 +483,7 @@ int
|
||||
resolve_unknown_type(const char * path, media_types dir_type)
|
||||
{
|
||||
struct stat entry;
|
||||
unsigned char type = TYPE_UNKNOWN;
|
||||
enum file_types type = TYPE_UNKNOWN;
|
||||
char str_buf[PATH_MAX];
|
||||
ssize_t len;
|
||||
|
||||
@ -489,33 +510,24 @@ resolve_unknown_type(const char * path, media_types dir_type)
|
||||
}
|
||||
else if( S_ISREG(entry.st_mode) )
|
||||
{
|
||||
switch( dir_type )
|
||||
{
|
||||
case ALL_MEDIA:
|
||||
if( is_image(path) ||
|
||||
is_audio(path) ||
|
||||
is_video(path) ||
|
||||
is_playlist(path) )
|
||||
type = TYPE_FILE;
|
||||
break;
|
||||
case TYPE_AUDIO:
|
||||
if( is_audio(path) ||
|
||||
is_playlist(path) )
|
||||
type = TYPE_FILE;
|
||||
break;
|
||||
case TYPE_VIDEO:
|
||||
if( is_video(path) )
|
||||
type = TYPE_FILE;
|
||||
break;
|
||||
case TYPE_IMAGES:
|
||||
if( is_image(path) )
|
||||
type = TYPE_FILE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
media_types mtype = get_media_type(path);
|
||||
if (dir_type & mtype)
|
||||
type = TYPE_FILE;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
media_types
|
||||
valid_media_types(const char *path)
|
||||
{
|
||||
struct media_dir_s *media_dir;
|
||||
|
||||
for (media_dir = media_dirs; media_dir; media_dir = media_dir->next)
|
||||
{
|
||||
if (strncmp(path, media_dir->path, strlen(media_dir->path)) == 0)
|
||||
return media_dir->types;
|
||||
}
|
||||
|
||||
return ALL_MEDIA;
|
||||
}
|
||||
|
Reference in New Issue
Block a user