mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
(trunk daemon) #2943 "watch.c matches everything containing '.torrent'" -- use Longinus00's patch to fix this in trunk for 1.91
This commit is contained in:
parent
fa7292cde7
commit
95236d1f3e
1 changed files with 14 additions and 2 deletions
|
@ -40,6 +40,18 @@ struct dtr_watchdir
|
|||
#endif
|
||||
};
|
||||
|
||||
static tr_bool
|
||||
str_has_suffix( const char *str, const char *suffix )
|
||||
{
|
||||
const size_t str_len = strlen( str );
|
||||
const size_t suffix_len = strlen( suffix );
|
||||
|
||||
if( str_len < suffix_len )
|
||||
return FALSE;
|
||||
|
||||
return !strncasecmp( str + str_len - suffix_len, suffix, suffix_len );
|
||||
}
|
||||
|
||||
/***
|
||||
**** INOTIFY IMPLEMENTATION
|
||||
***/
|
||||
|
@ -99,7 +111,7 @@ watchdir_update_impl( dtr_watchdir * w )
|
|||
int len = read( fd, buf, sizeof( buf ) );
|
||||
while (i < len) {
|
||||
struct inotify_event * event = (struct inotify_event *) &buf[i];
|
||||
if( strstr( event->name, ".torrent" ) != NULL )
|
||||
if( str_has_suffix( event->name, ".torrent" ) )
|
||||
{
|
||||
tr_inf( "Found new .torrent file \"%s\" in watchdir \"%s\"", event->name, w->dir );
|
||||
w->callback( w->session, w->dir, event->name );
|
||||
|
@ -170,7 +182,7 @@ watchdir_update_impl( dtr_watchdir * w )
|
|||
|
||||
if( !d->d_name || *d->d_name=='.' ) /* skip dotfiles */
|
||||
continue;
|
||||
if( !strstr( d->d_name, ".torrent" ) ) /* skip non-torrents */
|
||||
if( !str_has_suffix( event->name, ".torrent" ) ) /* skip non-torrents */
|
||||
continue;
|
||||
|
||||
len = strlen( d->d_name );
|
||||
|
|
Loading…
Reference in a new issue