1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

provide feedback on failure cause if plugin installation fails

This commit is contained in:
Philip Flohr 2018-05-07 18:27:01 +02:00 committed by Dmitry Podgorny
parent adb4955c34
commit 1f66c08567
3 changed files with 10 additions and 6 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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);