mirror of
				https://github.com/packwiz/packwiz.git
				synced 2025-11-04 12:04:31 +01:00 
			
		
		
		
	Clarify hash mismatch error in mod.go and also check with uppercase hash
This commit is contained in:
		@@ -8,6 +8,8 @@ import (
 | 
				
			|||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/BurntSushi/toml"
 | 
						"github.com/BurntSushi/toml"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -146,8 +148,8 @@ func (m Mod) DownloadFile(dest io.Writer) error {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	calculatedHash := hex.EncodeToString(h.Sum(nil))
 | 
						calculatedHash := hex.EncodeToString(h.Sum(nil))
 | 
				
			||||||
	if calculatedHash != m.Download.Hash {
 | 
						if calculatedHash != m.Download.Hash && strings.ToUpper(calculatedHash) != m.Download.Hash {
 | 
				
			||||||
		return errors.New("hash of saved file is invalid")
 | 
							return errors.New(fmt.Sprintf("hash of saved file is invalid!\n .toml hash: %s\n download hash: %s", calculatedHash, m.Download.Hash))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user