* Add file filters to inotify scanner. Now, for example, an audio-only directory should not have image or video files put in the database by the inotify auto-scanner.
This commit is contained in:
parent
ea70f079f2
commit
608f3f902c
48
inotify.c
48
inotify.c
@ -264,7 +264,44 @@ inotify_insert_file(char * name, const char * path)
|
||||
char * parent_buf = NULL;
|
||||
char * id = NULL;
|
||||
int depth = 1;
|
||||
enum media_types type = ALL_MEDIA;
|
||||
struct media_dir_s * media_path = media_dirs;
|
||||
|
||||
/* Check if we're supposed to be scanning for this file type in this directory */
|
||||
while( media_path )
|
||||
{
|
||||
if( strncmp(path, media_path->path, strlen(media_path->path)) == 0 )
|
||||
{
|
||||
type = media_path->type;
|
||||
break;
|
||||
}
|
||||
media_path = media_path->next;
|
||||
}
|
||||
switch( type )
|
||||
{
|
||||
case ALL_MEDIA:
|
||||
if( !is_image(path) &&
|
||||
!is_audio(path) &&
|
||||
!is_video(path) )
|
||||
return -1;
|
||||
break;
|
||||
case AUDIO_ONLY:
|
||||
if( !is_audio(path) )
|
||||
return -1;
|
||||
break;
|
||||
case VIDEO_ONLY:
|
||||
if( !is_video(path) )
|
||||
return -1;
|
||||
break;
|
||||
case IMAGES_ONLY:
|
||||
if( !is_image(path) )
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* If it's already in the database, just skip it for now.
|
||||
* TODO: compare modify timestamps */
|
||||
sql = sqlite3_mprintf("SELECT ID from DETAILS where PATH = '%q'", path);
|
||||
@ -562,9 +599,14 @@ start_inotify()
|
||||
i = 0;
|
||||
while( i < length )
|
||||
{
|
||||
struct inotify_event * event = ( struct inotify_event * ) &buffer[ i ];
|
||||
if ( event->len )
|
||||
struct inotify_event * event = (struct inotify_event *) &buffer[i];
|
||||
if( event->len )
|
||||
{
|
||||
if( *(event->name) == '.' )
|
||||
{
|
||||
i += EVENT_SIZE + event->len;
|
||||
continue;
|
||||
}
|
||||
esc_name = modifyString(strdup(event->name), "&", "&amp;", 0);
|
||||
asprintf(&path_buf, "%s/%s", get_path_from_wd(event->wd), event->name);
|
||||
if ( (event->mask & IN_CREATE && event->mask & IN_ISDIR) ||
|
||||
@ -600,5 +642,5 @@ start_inotify()
|
||||
inotify_remove_watches(fd);
|
||||
close(fd);
|
||||
|
||||
exit( 0 );
|
||||
return NULL;
|
||||
}
|
||||
|
@ -46,12 +46,13 @@ int
|
||||
is_video(const char * file)
|
||||
{
|
||||
return (ends_with(file, ".mpg") || ends_with(file, ".mpeg") ||
|
||||
ends_with(file, ".avi") || ends_with(file, ".divx") ||
|
||||
ends_with(file, ".asf") || ends_with(file, ".wmv") ||
|
||||
ends_with(file, ".mp4") || ends_with(file, ".m4v") ||
|
||||
ends_with(file, ".mts") || ends_with(file, ".m2ts") ||
|
||||
ends_with(file, ".m2t") || ends_with(file, ".mkv") ||
|
||||
ends_with(file, ".vob") || ends_with(file, ".ts") ||
|
||||
ends_with(file, ".avi") || ends_with(file, ".xvid"));
|
||||
ends_with(file, ".flv") || ends_with(file, ".xvid"));
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
x
Reference in New Issue
Block a user