瀏覽代碼

eventmanager: don't modify in place fs events paths

Signed-off-by: Nicola Murino <[email protected]>
Nicola Murino 2 年之前
父節點
當前提交
5605496c5f
共有 3 個文件被更改,包括 7 次插入6 次删除
  1. 4 3
      internal/common/eventmanager.go
  2. 1 1
      templates/webadmin/admin.html
  3. 2 2
      templates/webadmin/eventrule.html

+ 4 - 3
internal/common/eventmanager.go

@@ -1239,10 +1239,11 @@ func getUserForEventAction(user dataprovider.User) (dataprovider.User, error) {
 }
 
 func replacePathsPlaceholders(paths []string, replacer *strings.Replacer) []string {
-	for idx := range paths {
-		paths[idx] = util.CleanPath(replaceWithReplacer(paths[idx], replacer))
+	results := make([]string, 0, len(paths))
+	for _, p := range paths {
+		results = append(results, util.CleanPath(replaceWithReplacer(p, replacer)))
 	}
-	return util.RemoveDuplicates(paths, false)
+	return util.RemoveDuplicates(results, false)
 }
 
 func executeDeleteFileFsAction(conn *BaseConnection, item string, info os.FileInfo) error {

+ 1 - 1
templates/webadmin/admin.html

@@ -229,7 +229,7 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 <script src="{{.StaticURL}}/vendor/bootstrap-select/js/bootstrap-select.min.js"></script>
 <script type="text/javascript">
     $("body").on("click", ".add_new_group_field_btn", function () {
-        var index = $(".form_field_groups_outer").find("form_field_groups_outer_row").length;
+        var index = $(".form_field_groups_outer").find(".form_field_groups_outer_row").length;
         while (document.getElementById("idGroup"+index) != null){
             index++;
         }

+ 2 - 2
templates/webadmin/eventrule.html

@@ -543,7 +543,7 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
     });
 
     $("body").on("click", ".add_new_fs_path_pattern_field_btn", function () {
-        var index = $(".form_field_fs_paths_outer").find("form_field_fs_paths_outer_row").length;
+        var index = $(".form_field_fs_paths_outer").find(".form_field_fs_paths_outer_row").length;
         while (document.getElementById("idFsPathPattern"+index) != null){
             index++;
         }
@@ -573,7 +573,7 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
     });
 
     $("body").on("click", ".add_new_action_field_btn", function () {
-        var index = $(".form_field_action_outer").find("form_field_action_outer_row").length;
+        var index = $(".form_field_action_outer").find(".form_field_action_outer_row").length;
         while (document.getElementById("idActionName"+index) != null){
             index++;
         }