(rpc) 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
7f53889db5
commit
8ced51a9e4
|
@ -610,13 +610,6 @@ tr_getClutchDir( const tr_session * session UNUSED )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !*path )
|
|
||||||
{
|
|
||||||
tr_strlcpy( path, "/dev/null", sizeof( path ) );
|
|
||||||
tr_err( _(
|
|
||||||
"Couldn't find the web interface's files! To customize this, set the CLUTCH_HOME environmental variable to the folder where index.html is located." ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
s = tr_strdup( path );
|
s = tr_strdup( path );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ send_simple_response( struct evhttp_request * req,
|
||||||
|
|
||||||
evbuffer_add_printf( body, "<h1>%d: %s</h1>", code, code_text );
|
evbuffer_add_printf( body, "<h1>%d: %s</h1>", code, code_text );
|
||||||
if( text )
|
if( text )
|
||||||
evbuffer_add_printf( body, "<h2>%s</h2>", text );
|
evbuffer_add_printf( body, "%s", text );
|
||||||
evhttp_send_reply( req, code, code_text, body );
|
evhttp_send_reply( req, code, code_text, body );
|
||||||
evbuffer_free( body );
|
evbuffer_free( body );
|
||||||
}
|
}
|
||||||
|
@ -320,13 +320,28 @@ static void
|
||||||
handle_clutch( struct evhttp_request * req,
|
handle_clutch( struct evhttp_request * req,
|
||||||
struct tr_rpc_server * server )
|
struct tr_rpc_server * server )
|
||||||
{
|
{
|
||||||
char * pch;
|
|
||||||
char * subpath;
|
|
||||||
char * filename;
|
|
||||||
const char * clutchDir = tr_getClutchDir( server->session );
|
const char * clutchDir = tr_getClutchDir( server->session );
|
||||||
|
|
||||||
assert( !strncmp( req->uri, "/transmission/web/", 18 ) );
|
assert( !strncmp( req->uri, "/transmission/web/", 18 ) );
|
||||||
|
|
||||||
|
if( !clutchDir || !*clutchDir )
|
||||||
|
{
|
||||||
|
send_simple_response( req, HTTP_NOTFOUND,
|
||||||
|
"<p>Couldn't find Transmission's web interface files!</p>"
|
||||||
|
"<p>Users: to tell Transmission where to look, "
|
||||||
|
"set the TRANSMISSION_WEB_HOME environmental "
|
||||||
|
"variable to the folder where the web interface's "
|
||||||
|
"index.html is located.</p>"
|
||||||
|
"<p>Package Builders: to set a custom default at compile time, "
|
||||||
|
"#define PACKAGE_DATA_DIR in libtransmission/platform.c "
|
||||||
|
"or tweak tr_getClutchDir() by hand.</p>" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char * pch;
|
||||||
|
char * subpath;
|
||||||
|
char * filename;
|
||||||
|
|
||||||
subpath = tr_strdup( req->uri + 18 );
|
subpath = tr_strdup( req->uri + 18 );
|
||||||
if(( pch = strchr( subpath, '?' )))
|
if(( pch = strchr( subpath, '?' )))
|
||||||
*pch = '\0';
|
*pch = '\0';
|
||||||
|
@ -339,6 +354,7 @@ handle_clutch( struct evhttp_request * req,
|
||||||
|
|
||||||
tr_free( filename );
|
tr_free( filename );
|
||||||
tr_free( subpath );
|
tr_free( subpath );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue