1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 17:23:15 +02:00

core, plugins: abort upgrade immediately if any upgrade file fails to be written

Detail of changes:

- the save of upgrade files in plugins is now done as soon as the "upgrade"
  signal is received, and not when the plugin is unloaded (it was too late to
  detect any problem and prevent the upgrade to happen)
- if the write of an upgrade file fails, the signal callback in plugin now
  returns WEECHAT_RC_ERROR and WeeChat checks this code to stop the upgrade as
  soon as this return code is received
- a new flag is added in plugin structure: unload_with_upgrade, it is set to 1
  before unloading all plugins when upgrade will happen (all *.upgrade files
  are then already successfully written).
This commit is contained in:
Sébastien Helleu
2024-11-24 10:07:05 +01:00
parent 244595d94f
commit 328aa8f202
26 changed files with 298 additions and 54 deletions
+36 -3
View File
@@ -7200,6 +7200,7 @@ command_upgrade_display (struct t_gui_buffer *buffer,
COMMAND_CALLBACK(upgrade)
{
struct t_weechat_plugin *ptr_plugin;
char *ptr_binary;
char *exec_args[7] = { NULL, "-a", "--dir", NULL, "--upgrade", NULL };
struct stat stat_buf;
@@ -7253,7 +7254,16 @@ COMMAND_CALLBACK(upgrade)
&& (string_strcmp (argv[index_args], "-save") == 0))
{
/* send "upgrade" signal to plugins */
(void) hook_signal_send ("upgrade", WEECHAT_HOOK_SIGNAL_STRING, "save");
rc = hook_signal_send ("[flags:stop_on_error,ignore_eat]upgrade",
WEECHAT_HOOK_SIGNAL_STRING, "save");
if (rc == WEECHAT_RC_ERROR)
{
gui_chat_printf (NULL,
_("%sUnable to save some plugin sessions "
"(files *.upgrade)"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return WEECHAT_RC_ERROR;
}
/* save WeeChat session */
if (!upgrade_weechat_save ())
{
@@ -7353,19 +7363,42 @@ COMMAND_CALLBACK(upgrade)
}
/* send "upgrade" signal to plugins */
(void) hook_signal_send ("upgrade", WEECHAT_HOOK_SIGNAL_STRING,
(quit) ? "quit" : NULL);
rc = hook_signal_send ("[flags:stop_on_error,ignore_eat]upgrade",
WEECHAT_HOOK_SIGNAL_STRING,
(quit) ? "quit" : NULL);
if (rc == WEECHAT_RC_ERROR)
{
gui_chat_printf (NULL,
_("%sUnable to save some plugin sessions "
"(files *.upgrade)"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
gui_chat_printf (NULL,
_("%sUpgrade aborted"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
free (ptr_binary);
return WEECHAT_RC_ERROR;
}
/* save WeeChat session */
if (!upgrade_weechat_save ())
{
gui_chat_printf (NULL,
_("%sUnable to save WeeChat session "
"(files *.upgrade)"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
gui_chat_printf (NULL,
_("%sUpgrade aborted"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
free (ptr_binary);
return WEECHAT_RC_ERROR;
}
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
ptr_plugin->unload_with_upgrade = 1;
}
weechat_quit = 1;
weechat_upgrading = 1;