Commit e8c856b9 authored by François Cartegnie's avatar François Cartegnie 🤞

metaengine: folder: test uri against folder first. (fix #10380)

because make_path strips last segment
parent 177078ba
......@@ -75,24 +75,54 @@ static int FindMeta( vlc_object_t *p_this )
art_finder_t *p_finder = (art_finder_t *)p_this;
input_item_t *p_item = p_finder->p_item;
bool b_have_art = false;
struct stat statinfo;
char *psz_path = NULL;
if( !p_item )
return VLC_EGENERIC;
char *psz_dir = input_item_GetURI( p_item );
if( !psz_dir )
char *psz_uri = input_item_GetURI( p_item );
if( !psz_uri )
return VLC_EGENERIC;
char *psz_path = make_path( psz_dir );
free( psz_dir );
if( psz_path == NULL )
return VLC_EGENERIC;
if ( *psz_uri && psz_uri[strlen( psz_uri ) - 1] != DIR_SEP_CHAR )
{
if ( asprintf( &psz_path, "%s"DIR_SEP, psz_uri ) == -1 )
{
free( psz_uri );
return VLC_EGENERIC;
}
char *psz_basedir = make_path( psz_path );
FREENULL( psz_path );
if( psz_basedir == NULL )
{
free( psz_uri );
return VLC_EGENERIC;
}
if( vlc_stat( psz_basedir, &statinfo ) == 0 && S_ISDIR(statinfo.st_mode) )
psz_path = psz_basedir;
else
free( psz_basedir );
}
if ( psz_path == NULL )
{
char *psz_basedir = make_path( psz_uri );
if( psz_basedir == NULL )
{
free( psz_uri );
return VLC_EGENERIC;
}
char *psz_buf = strrchr( psz_basedir, DIR_SEP_CHAR );
if( psz_buf )
*++psz_buf = '\0';
else
*psz_basedir = '\0'; /* relative path */
psz_path = psz_basedir;
}
char *psz_buf = strrchr( psz_path, DIR_SEP_CHAR );
if( psz_buf )
*++psz_buf = '\0';
else
*psz_path = '\0'; /* relative path */
free( psz_uri );
for( int i = -1; !b_have_art && i < i_covers; i++ )
{
......@@ -118,8 +148,7 @@ static int FindMeta( vlc_object_t *p_this )
if( unlikely(filepath == NULL) )
continue;
struct stat dummy;
if( vlc_stat( filepath, &dummy ) == 0 )
if( vlc_stat( filepath, &statinfo ) == 0 && S_ISREG(statinfo.st_mode) )
{
char *psz_uri = vlc_path2uri( filepath, "file" );
if( psz_uri )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment