From 4b3f9b1af97027c06ed440098af899be041e217e Mon Sep 17 00:00:00 2001 From: xduugu Date: Fri, 12 Jul 2019 07:45:39 +0000 Subject: [PATCH] lib/versioner: Replace multiple placeholders in a single token in external command (fixes #5849) * lib/versioner: Add placeholder to provide the absolute file path to external commands This commit adds support for a new placeholder, %FILE_PATH_FULL%, to the command of the external versioner. The placeholder will be replaced by the absolute path of the file that should be deleted. * Revert "lib/versioner: Add placeholder to provide the absolute file path to external commands" This reverts commit fb48962b947358e90a76e87a7794adb6057de476. * lib/versioner: Replace all placeholders in external command (fixes #5849) Before this commit, only these placeholders were replaced that span a whole word, for example "%FOLDER_PATH%". Words that consisted of more than one placeholder or additional characters, for example "%FOLDER_PATH%/%FILE_PATH%", were left untouched. * fixup! lib/versioner: Replace all placeholders in external command (fixes #5849) --- lib/versioner/external.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/versioner/external.go b/lib/versioner/external.go index d2276fe05..9a7a687a9 100644 --- a/lib/versioner/external.go +++ b/lib/versioner/external.go @@ -77,9 +77,11 @@ func (v External) Archive(filePath string) error { } for i, word := range words { - if replacement, ok := context[word]; ok { - words[i] = replacement + for key, val := range context { + word = strings.Replace(word, key, val, -1) } + + words[i] = word } cmd := exec.Command(words[0], words[1:]...)