Fix the god damn disgusting windows path
This commit is contained in:
@@ -34,7 +34,6 @@ func init() {
|
|||||||
const remoteUrl = "https://git.site.quack-lab.dev/dave/barotrauma-gamefiles/raw/branch/cooked/Content"
|
const remoteUrl = "https://git.site.quack-lab.dev/dave/barotrauma-gamefiles/raw/branch/cooked/Content"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
savehash := flag.Bool("savehash", false, "save hash")
|
|
||||||
hashfile := flag.String("hashfile", "hashes.txt", "hashfile")
|
hashfile := flag.String("hashfile", "hashes.txt", "hashfile")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@@ -72,7 +71,9 @@ func main() {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(file string) {
|
go func(file string) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
file = strings.ReplaceAll(file, "\\", "/")
|
||||||
path := filepath.Join(root, file)
|
path := filepath.Join(root, file)
|
||||||
|
path = strings.ReplaceAll(path, "\\", "/")
|
||||||
hash, err := GetLocalHash(path)
|
hash, err := GetLocalHash(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error.Printf("error getting hash: %v", err)
|
Error.Printf("error getting hash: %v", err)
|
||||||
@@ -83,6 +84,7 @@ func main() {
|
|||||||
Error.Printf("error getting relative path: %v", err)
|
Error.Printf("error getting relative path: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
relativepath = strings.ReplaceAll(relativepath, "\\", "/")
|
||||||
hashes.Store(relativepath, hash)
|
hashes.Store(relativepath, hash)
|
||||||
}(file)
|
}(file)
|
||||||
}
|
}
|
||||||
@@ -128,17 +130,22 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
Error.Printf("error updating local file: %v", err)
|
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)
|
}(file)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
if *savehash {
|
// We want to update the newly downloaded files, if any
|
||||||
err := SaveLocalHashes(*hashfile, hashes)
|
err = SaveLocalHashes(*hashfile, hashes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error.Printf("error saving hashes: %v", err)
|
Error.Printf("error saving hashes: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func GetLocalHash(path string) (string, error) {
|
func GetLocalHash(path string) (string, error) {
|
||||||
hash := sha256.New()
|
hash := sha256.New()
|
||||||
@@ -183,6 +190,7 @@ type FileHash struct {
|
|||||||
Path string
|
Path string
|
||||||
Hash string
|
Hash string
|
||||||
}
|
}
|
||||||
|
|
||||||
func SaveLocalHashes(path string, hashes *sync.Map) error {
|
func SaveLocalHashes(path string, hashes *sync.Map) error {
|
||||||
file, err := os.Create(path)
|
file, err := os.Create(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user