From faec4f47389055f8fdfa15514e154a0cb81553da Mon Sep 17 00:00:00 2001 From: Tricked <72335827+SkyBlockDev@users.noreply.github.com> Date: Wed, 15 Jun 2022 21:17:55 +0200 Subject: [PATCH] use sha1 instead of sha256 --- github/install.go | 13 +++++++++---- github/updater.go | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/github/install.go b/github/install.go index 9a7aa2d..7a9437b 100644 --- a/github/install.go +++ b/github/install.go @@ -93,7 +93,12 @@ func fetchMod(slug string) (Mod, error) { repoResp, err := http.Get(githubApiUrl + "repos/" + slug) + if err != nil { + return mod, err + } + defer repoResp.Body.Close() + repoBody, err := ioutil.ReadAll(repoResp.Body) if err != nil { return mod, err @@ -209,7 +214,7 @@ func installVersion(mod Mod, version ModReleases, pack core.Pack) error { return err } - hash, error := file.getSha256() + hash, error := file.getSha1() if error != nil || hash == "" { return errors.New("file doesn't have a hash") } @@ -220,7 +225,7 @@ func installVersion(mod Mod, version ModReleases, pack core.Pack) error { Side: "unknown", Download: core.ModDownload{ URL: file.BrowserDownloadURL, - HashFormat: "sha256", + HashFormat: "sha1", Hash: hash, }, Update: updateMap, @@ -336,9 +341,9 @@ type Asset struct { BrowserDownloadURL string `json:"browser_download_url"` } -func (u Asset) getSha256() (string, error) { +func (u Asset) getSha1() (string, error) { // TODO potentionally cache downloads to speed things up and avoid getting ratelimited by github! - mainHasher, err := core.GetHashImpl("sha256") + mainHasher, err := core.GetHashImpl("sha1") resp, err := http.Get(u.BrowserDownloadURL) if err != nil { return "", err diff --git a/github/updater.go b/github/updater.go index 587d864..32e74a8 100644 --- a/github/updater.go +++ b/github/updater.go @@ -80,7 +80,7 @@ func (u ghUpdater) DoUpdate(mods []*core.Mod, cachedState []interface{}) error { } } - hash, error := file.getSha256() + hash, error := file.getSha1() if error != nil || hash == "" { return errors.New("file doesn't have a hash") } @@ -88,7 +88,7 @@ func (u ghUpdater) DoUpdate(mods []*core.Mod, cachedState []interface{}) error { mod.FileName = file.Name mod.Download = core.ModDownload{ URL: file.BrowserDownloadURL, - HashFormat: "sha256", + HashFormat: "sha1", Hash: hash, } mod.Update["github"]["version"] = version.ID