summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/plugin-script.c15
-rw-r--r--src/plugins/script/script-action.c15
3 files changed, 24 insertions, 7 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 57a5d56cb..7e648623b 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -43,6 +43,7 @@ Bug fixes::
* irc: add missing tags on CTCP message sent
* lua: fix integers returned in Lua >= 5.3 (issue #834)
* relay: set status to "authentication failed" and close immediately connection in case of authentication failure in weechat and irc protocols (issue #825)
+ * script: reload a script after upgrade only if it was loaded, set autoload only if the script was auto-loaded (issue #855)
Build::
diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c
index 4a2bc98d3..40ac79e43 100644
--- a/src/plugins/plugin-script.c
+++ b/src/plugins/plugin-script.c
@@ -1085,7 +1085,7 @@ plugin_script_remove_file (struct t_weechat_plugin *weechat_plugin,
* 2. removes script file(s)
* 3. moves script file from "install" dir to language dir
* 4. makes link in autoload dir (if option "-a" is given)
- * 5. loads script.
+ * 5. loads script (if it was loaded).
*/
void
@@ -1099,7 +1099,7 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
char **argv, *name, *ptr_base_name, *base_name, *new_path, *autoload_path;
char *symlink_path, str_signal[128], *ptr_list;
const char *dir_home, *dir_separator;
- int argc, i, length, rc, autoload;
+ int argc, i, length, rc, autoload, script_loaded;
struct t_plugin_script *ptr_script;
if (!*list)
@@ -1120,7 +1120,7 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
{
switch (ptr_list[1])
{
- case 'a': /* no autoload */
+ case 'a': /* autoload */
autoload = 1;
break;
case 'q': /* quiet mode */
@@ -1144,10 +1144,14 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
if (base_name)
{
/* unload script, if script is loaded */
+ script_loaded = 0;
ptr_script = plugin_script_search_by_full_name (scripts,
base_name);
if (ptr_script)
+ {
+ script_loaded = 1;
(*script_unload) (ptr_script);
+ }
/* remove script file(s) */
plugin_script_remove_file (weechat_plugin, base_name,
@@ -1193,8 +1197,9 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
}
}
- /* load script */
- (*script_load) (new_path);
+ /* load script (only if script was loaded) */
+ if (script_loaded)
+ (*script_load) (new_path);
}
else
{
diff --git a/src/plugins/script/script-action.c b/src/plugins/script/script-action.c
index 3c4510b8e..49def1e7a 100644
--- a/src/plugins/script/script-action.c
+++ b/src/plugins/script/script-action.c
@@ -506,7 +506,7 @@ script_action_install_process_cb (const void *pointer, void *data,
const char *err)
{
char *pos, *filename, *filename2, str_signal[256];
- int quiet, length;
+ int quiet, auto_load, length;
struct t_script_repo *ptr_script;
/* make C compiler happy */
@@ -543,10 +543,21 @@ script_action_install_process_cb (const void *pointer, void *data,
filename2 = malloc (length);
if (filename2)
{
+ auto_load = 0;
+ if (ptr_script->status & SCRIPT_STATUS_INSTALLED)
+ {
+ auto_load = (ptr_script->status & SCRIPT_STATUS_AUTOLOADED) ?
+ 1 : 0;
+ }
+ else
+ {
+ auto_load = weechat_config_boolean (
+ script_config_scripts_autoload);
+ }
snprintf (filename2, length,
"%s%s%s",
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
- (weechat_config_boolean (script_config_scripts_autoload)) ? "-a " : "",
+ (auto_load) ? "-a " : "",
filename);
snprintf (str_signal, sizeof (str_signal),
"%s_script_install",