]> granicus.if.org Git - transmission/commitdiff
(rpc) if libt can't find the Clutch files, give a helpful 404 message for end-users...
authorCharles Kerr <charles@transmissionbt.com>
Tue, 7 Oct 2008 01:25:29 +0000 (01:25 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Tue, 7 Oct 2008 01:25:29 +0000 (01:25 +0000)
libtransmission/platform.c
libtransmission/rpc-server.c

index 14b2a7bf4f2fac84e5fd67e79d8b75c42253e2a7..cfcf7a04901ce4832fa1cf6c7e2b9b47b4936be8 100644 (file)
@@ -610,13 +610,6 @@ tr_getClutchDir( const tr_session * session UNUSED )
 #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 );
     }
 
index 8aaad594db8b4afbe6dd3eb9cc215e03047f7712..99c69a61d18cb5e786931912992af897d0e34883 100644 (file)
@@ -70,7 +70,7 @@ send_simple_response( struct evhttp_request * req,
 
     evbuffer_add_printf( body, "<h1>%d: %s</h1>", code, code_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 );
     evbuffer_free( body );
 }
@@ -320,25 +320,41 @@ static void
 handle_clutch( struct evhttp_request * req,
                struct tr_rpc_server *  server )
 {
-    char * pch;
-    char * subpath;
-    char * filename;
     const char * clutchDir = tr_getClutchDir( server->session );
 
     assert( !strncmp( req->uri, "/transmission/web/", 18 ) );
 
-    subpath = tr_strdup( req->uri + 18 );
-    if(( pch = strchr( subpath, '?' )))
-        *pch = '\0';
+    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 );
+        if(( pch = strchr( subpath, '?' )))
+            *pch = '\0';
 
-    filename = *subpath
-        ? tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, subpath )
-        : tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, "index.html" );
+        filename = *subpath
+            ? tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, subpath )
+            : tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, "index.html" );
 
-    serve_file( req, filename );
+        serve_file( req, filename );
 
-    tr_free( filename );
-    tr_free( subpath );
+        tr_free( filename );
+        tr_free( subpath );
+    }
 }
 
 static void