mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
(rpc) fix r6861 regression: if libt can't find the Clutch files, give a helpful 404 message for end-users and binary packagers about how to use CLUTCH_HOME and PACKAGE_DATA_DIR.
This commit is contained in:
parent
c0192934b8
commit
e04ea4062d
1 changed files with 16 additions and 19 deletions
|
@ -567,37 +567,34 @@ tr_getClutchDir( const tr_session * session UNUSED )
|
|||
#else /* everyone else, follow the XDG spec */
|
||||
|
||||
tr_list *candidates = NULL, *l;
|
||||
const char * tmp;
|
||||
|
||||
/* XDG_DATA_HOME should be the first in the list of candidates */
|
||||
s = getenv( "XDG_DATA_HOME" );
|
||||
if( s && *s )
|
||||
tr_list_append( &candidates, tr_strdup( s ) );
|
||||
tmp = getenv( "XDG_DATA_HOME" );
|
||||
if( tmp && *tmp )
|
||||
tr_list_append( &candidates, tr_strdup( tmp ) );
|
||||
else {
|
||||
char * dhome = tr_buildPath( getHomeDir( ), ".local", "share", NULL );
|
||||
tr_list_append( &candidates, dhome );
|
||||
}
|
||||
|
||||
/* XDG_DATA_DIRS are the backup directories */
|
||||
s = getenv( "XDG_DATA_DIRS" );
|
||||
if( !s || !*s )
|
||||
s = PACKAGE_DATA_DIR ":/usr/local/share/:/usr/share/";
|
||||
while( s && *s )
|
||||
{
|
||||
char * end = strchr( s, ':' );
|
||||
if( end )
|
||||
{
|
||||
tr_list_append( &candidates, tr_strndup( s, end - s ) );
|
||||
s = end + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_list_append( &candidates, tr_strdup( s ) );
|
||||
tmp = getenv( "XDG_DATA_DIRS" );
|
||||
if( !tmp || !*tmp )
|
||||
tmp = PACKAGE_DATA_DIR ":/usr/local/share/:/usr/share/";
|
||||
while( tmp && *tmp ) {
|
||||
const char * end = strchr( tmp, ':' );
|
||||
if( end ) {
|
||||
tr_list_append( &candidates, tr_strndup( tmp, end - tmp ) );
|
||||
tmp = end + 1;
|
||||
} else {
|
||||
tr_list_append( &candidates, tr_strdup( tmp ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for( l = candidates; l; l = l->next )
|
||||
{
|
||||
/* walk through the candidates & look for a match */
|
||||
for( l=candidates; l; l=l->next ) {
|
||||
char * path = tr_buildPath( l->data, "transmission", "web", NULL );
|
||||
const int found = isClutchDir( path );
|
||||
if( found ) {
|
||||
|
|
Loading…
Reference in a new issue