diff options
-rw-r--r-- | src/command/cmd_funcs.c | 5 | ||||
-rw-r--r-- | src/plugins/plugins.c | 9 | ||||
-rw-r--r-- | src/plugins/plugins.h | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index c8aa22b4..a955e2f8 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -6616,12 +6616,13 @@ cmd_plugins_install(ProfWin *window, const char *const command, gchar **args) return TRUE; } + GString* error_message = g_string_new(NULL); gchar *plugin_name = g_path_get_basename(path); - gboolean result = plugins_install(plugin_name, path); + gboolean result = plugins_install(plugin_name, path, error_message); if (result) { cons_show("Plugin installed: %s", plugin_name); } else { - cons_show("Failed to install plugin: %s", plugin_name); + cons_show("Failed to install plugin: %s. %s", plugin_name, error_message->str); } g_free(plugin_name); diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index d10cf5b8..e63aec84 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -149,10 +149,12 @@ plugins_install_all(const char *const path) get_file_paths_recursive(path, &contents); GSList *curr = contents; + GString *error_message = NULL; while (curr) { + error_message = g_string_new(NULL); if (g_str_has_suffix(curr->data, ".py") || g_str_has_suffix(curr->data, ".so")) { gchar *plugin_name = g_path_get_basename(curr->data); - if (plugins_install(plugin_name, curr->data)) { + if (plugins_install(plugin_name, curr->data, error_message)) { result->installed = g_slist_append(result->installed, strdup(curr->data)); } else { result->failed = g_slist_append(result->failed, strdup(curr->data)); @@ -167,7 +169,7 @@ plugins_install_all(const char *const path) } gboolean -plugins_install(const char *const plugin_name, const char *const filename) +plugins_install(const char *const plugin_name, const char *const filename, GString *error_message) { char *plugins_dir = files_get_data_path(DIR_PLUGINS); GString *target_path = g_string_new(plugins_dir); @@ -175,9 +177,10 @@ plugins_install(const char *const plugin_name, const char *const filename) g_string_append(target_path, "/"); g_string_append(target_path, plugin_name); - if (g_file_test (filename,G_FILE_TEST_EXISTS)) + if (g_file_test (target_path->str, G_FILE_TEST_EXISTS)) { log_info("Failed to install plugin: %s, file exists", plugin_name); + g_string_assign(error_message, "File exists"); return FALSE; } diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h index 16d6874a..c787ee93 100644 --- a/src/plugins/plugins.h +++ b/src/plugins/plugins.h @@ -114,7 +114,7 @@ void plugins_shutdown(void); void plugins_free_install_result(PluginsInstallResult *result); -gboolean plugins_install(const char *const plugin_name, const char *const filename); +gboolean plugins_install(const char *const plugin_name, const char *const filename, GString * error_message); PluginsInstallResult* plugins_install_all(const char *const path); gboolean plugins_load(const char *const name); GSList* plugins_load_all(void); |