From ddc1d83d58f8f2dd2cafe3ef6011e2cdd997b6c6 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 22 Apr 2025 10:53:25 +0200 Subject: [PATCH] Fix file associations It was fucked because we were removing the static path and then cramming that into assications --- .vscode/launch.json | 13 +++++++++++++ main.go | 3 --- utils/modifycommand.go | 6 +++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 80fb126..28f5dc1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,6 +18,19 @@ "*.yml", ] }, + { + "name": "Launch Package (Payday 2)", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}", + "cwd": "C:/Users/Administrator/Seafile/Games-Payday2", + "args": [ + "-loglevel", + "trace", + "*.yml", + ] + }, { "name": "Launch Package (Barotrauma cookfile)", "type": "go", diff --git a/main.go b/main.go index 8a7b9a2..9699d68 100644 --- a/main.go +++ b/main.go @@ -141,9 +141,6 @@ func main() { logger.Debug("Created logger for command %q with log level %s", cmdName, cmdLogLevel.String()) } - // This aggregation is great but what if one modification replaces the whole entire file? - // Shit...... - // TODO: Add "Isolate" field to modifications which makes them run alone for file, association := range associations { workers <- struct{}{} wg.Add(1) diff --git a/utils/modifycommand.go b/utils/modifycommand.go index ce90090..04e8ed0 100644 --- a/utils/modifycommand.go +++ b/utils/modifycommand.go @@ -86,6 +86,7 @@ func AssociateFilesWithCommands(files []string, commands []ModifyCommand) (map[s fileCommands := make(map[string]FileCommandAssociation) for _, file := range files { + file = strings.ReplaceAll(file, "\\", "/") fileCommands[file] = FileCommandAssociation{ File: file, IsolateCommands: []ModifyCommand{}, @@ -94,9 +95,8 @@ func AssociateFilesWithCommands(files []string, commands []ModifyCommand) (map[s for _, command := range commands { for _, glob := range command.Files { static, pattern := SplitPattern(glob) - file = strings.ReplaceAll(file, "\\", "/") - file = strings.Replace(file, static+`/`, "", 1) - matches, err := Matches(file, pattern) + patternFile := strings.Replace(file, static+`/`, "", 1) + matches, err := Matches(patternFile, pattern) if err != nil { logger.Trace("Failed to match glob %s with file %s: %v", glob, file, err) continue