From 5945f8cc25b5ac5389cc210e9d243dfc798138fc Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 26 Mar 2025 21:06:19 +0100 Subject: [PATCH] Fix the god damn disgusting windows path --- updater/main.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/updater/main.go b/updater/main.go index 99044689..fc99c7d2 100644 --- a/updater/main.go +++ b/updater/main.go @@ -34,7 +34,6 @@ func init() { const remoteUrl = "https://git.site.quack-lab.dev/dave/barotrauma-gamefiles/raw/branch/cooked/Content" func main() { - savehash := flag.Bool("savehash", false, "save hash") hashfile := flag.String("hashfile", "hashes.txt", "hashfile") flag.Parse() @@ -72,7 +71,9 @@ func main() { wg.Add(1) go func(file string) { defer wg.Done() + file = strings.ReplaceAll(file, "\\", "/") path := filepath.Join(root, file) + path = strings.ReplaceAll(path, "\\", "/") hash, err := GetLocalHash(path) if err != nil { Error.Printf("error getting hash: %v", err) @@ -83,6 +84,7 @@ func main() { Error.Printf("error getting relative path: %v", err) return } + relativepath = strings.ReplaceAll(relativepath, "\\", "/") hashes.Store(relativepath, hash) }(file) } @@ -128,15 +130,20 @@ func main() { if err != nil { Error.Printf("error updating local file: %v", err) } + newhash, err := GetLocalHash(path) + if err != nil { + Error.Printf("error getting local hash: %v", err) + return + } + hashes.Store(file, newhash) }(file) } wg.Wait() } - if *savehash { - err := SaveLocalHashes(*hashfile, hashes) - if err != nil { - Error.Printf("error saving hashes: %v", err) - } + // We want to update the newly downloaded files, if any + err = SaveLocalHashes(*hashfile, hashes) + if err != nil { + Error.Printf("error saving hashes: %v", err) } } @@ -183,6 +190,7 @@ type FileHash struct { Path string Hash string } + func SaveLocalHashes(path string, hashes *sync.Map) error { file, err := os.Create(path) if err != nil {