From 49e026ee92f3856a11bcbab8c62637ecf8263247 Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Sun, 1 Nov 2020 12:20:45 -0800 Subject: [PATCH] Fix issue where remote URL defined using run-script-before was ignored. Previously, we were declaring that the m_remoteurl field be passed by reference to the Execute method. However, the OnStart method declared that the remoteurl variable was to be passed by reference. As a result, the caller (Controller.SetupCommonOptions) method never received the updated value. Now, the variables being passed by reference are made consistent. This fixes #3651. --- Duplicati/Library/Modules/Builtin/RunScript.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Duplicati/Library/Modules/Builtin/RunScript.cs b/Duplicati/Library/Modules/Builtin/RunScript.cs index be70ec078..e8188df22 100644 --- a/Duplicati/Library/Modules/Builtin/RunScript.cs +++ b/Duplicati/Library/Modules/Builtin/RunScript.cs @@ -153,16 +153,17 @@ namespace Duplicati.Library.Modules.Builtin public void OnStart(string operationname, ref string remoteurl, ref string[] localpath) { + if (!string.IsNullOrEmpty(m_requiredScript)) + Execute(m_requiredScript, "BEFORE", operationname, ref remoteurl, ref localpath, m_timeout, true, m_options, null, null); + + if (!string.IsNullOrEmpty(m_startScript)) + Execute(m_startScript, "BEFORE", operationname, ref remoteurl, ref localpath, m_timeout, false, m_options, null, null); + + // Save options that might be set by a --run-script-before script so that the OnFinish method + // references the same values. m_operationName = operationname; m_remoteurl = remoteurl; m_localpath = localpath; - - - if (!string.IsNullOrEmpty(m_requiredScript)) - Execute(m_requiredScript, "BEFORE", m_operationName, ref m_remoteurl, ref m_localpath, m_timeout, true, m_options, null, null); - - if (!string.IsNullOrEmpty(m_startScript)) - Execute(m_startScript, "BEFORE", m_operationName, ref m_remoteurl, ref m_localpath, m_timeout, false, m_options, null, null); } public void OnFinish (object result)