mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Fix /plugins update
Before it tried to unload the plugin first and check the output. But if broken plugin was loaded, then it couldn't unload it, so before it require uninstall and install after it, making update useless for plugin development purposes. Unload is part of the uninstall so no unload is needed inside of the cmd function. Refactoring of cmd_plugins_update.
This commit is contained in:
parent
96f9a84f01
commit
a54e5413ca
@ -7120,51 +7120,42 @@ cmd_plugins_install(ProfWin* window, const char* const command, gchar** args)
|
|||||||
gboolean
|
gboolean
|
||||||
cmd_plugins_update(ProfWin* window, const char* const command, gchar** args)
|
cmd_plugins_update(ProfWin* window, const char* const command, gchar** args)
|
||||||
{
|
{
|
||||||
char* path;
|
|
||||||
|
|
||||||
if (args[1] == NULL) {
|
if (args[1] == NULL) {
|
||||||
cons_bad_cmd_usage(command);
|
cons_bad_cmd_usage(command);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
|
||||||
path = get_expanded_path(args[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto_gchar gchar* path = get_expanded_path(args[1]);
|
||||||
|
|
||||||
if (access(path, R_OK) != 0) {
|
if (access(path, R_OK) != 0) {
|
||||||
cons_show("File not found: %s", path);
|
cons_show("File not found: %s", path);
|
||||||
free(path);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_regular_file(path)) {
|
if (!is_regular_file(path)) {
|
||||||
|
cons_show("Argument must be a file.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_str_has_suffix(path, ".py") && !g_str_has_suffix(path, ".so")) {
|
if (!g_str_has_suffix(path, ".py") && !g_str_has_suffix(path, ".so")) {
|
||||||
cons_show("Plugins must have one of the following extensions: '.py' '.so'");
|
cons_show("Plugins must have one of the following extensions: '.py' or '.so'");
|
||||||
free(path);
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto_gchar gchar* plugin_name = g_path_get_basename(path);
|
||||||
|
if (!plugins_uninstall(plugin_name)) {
|
||||||
|
cons_show("Failed to uninstall plugin: %s.", plugin_name);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GString* error_message = g_string_new(NULL);
|
GString* error_message = g_string_new(NULL);
|
||||||
gchar* plugin_name = g_path_get_basename(path);
|
|
||||||
if (plugins_unload(plugin_name)) {
|
|
||||||
if (plugins_uninstall(plugin_name)) {
|
|
||||||
if (plugins_install(plugin_name, path, error_message)) {
|
if (plugins_install(plugin_name, path, error_message)) {
|
||||||
cons_show("Plugin installed: %s", plugin_name);
|
cons_show("Plugin installed: %s", plugin_name);
|
||||||
} else {
|
} else {
|
||||||
cons_show("Failed to install plugin: %s. %s", plugin_name, error_message->str);
|
cons_show("Failed to install plugin: %s. %s", plugin_name, error_message->str);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
cons_show("Failed to uninstall plugin: %s.", plugin_name);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cons_show("Failed to unload plugin: %s.", plugin_name);
|
|
||||||
}
|
|
||||||
g_free(plugin_name);
|
|
||||||
g_string_free(error_message, TRUE);
|
|
||||||
free(path);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(path);
|
g_string_free(error_message, TRUE);
|
||||||
cons_show("Argument must be a file.");
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user