diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index e9063d97..ab60482f 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -270,7 +270,7 @@ func (b *Binary) Install() error { return err } - pm, err := bootstrapper.FetchPackageManifest(&b.Version) + manifest, err := bootstrapper.FetchPackageManifest(&b.Version) if err != nil { return err } @@ -280,22 +280,12 @@ func (b *Binary) Install() error { } b.Splash.SetMessage("Downloading " + b.Alias) - if err := b.DownloadPackages(&pm); err != nil { + if err := b.DownloadPackages(&manifest); err != nil { return err } b.Splash.SetMessage("Extracting " + b.Alias) - if err := b.ExtractPackages(&pm); err != nil { - return err - } - - m, err := bootstrapper.FetchManifest(&b.Version) - if err != nil { - return err - } - - b.Splash.SetMessage("Verifying " + b.Alias) - if err := b.VerifyFiles(m); err != nil { + if err := b.ExtractPackages(&manifest); err != nil { return err } @@ -312,7 +302,7 @@ func (b *Binary) Install() error { return err } - if err := state.SavePackageManifest(&pm); err != nil { + if err := state.SavePackageManifest(&manifest); err != nil { return err } @@ -324,7 +314,7 @@ func (b *Binary) Install() error { } func (b *Binary) PerformPackages(pm *bootstrapper.PackageManifest, fn func(bootstrapper.Package) error) error { - pkgsDone := 0 + donePkgs := 0 pkgsLen := len(pm.Packages) return pm.Packages.Perform(func(pkg bootstrapper.Package) error { @@ -333,8 +323,8 @@ func (b *Binary) PerformPackages(pm *bootstrapper.PackageManifest, fn func(boots return err } - pkgsDone++ - b.Splash.SetProgress(float32(pkgsDone) / float32(pkgsLen)) + donePkgs++ + b.Splash.SetProgress(float32(donePkgs) / float32(pkgsLen)) return nil }) @@ -363,25 +353,6 @@ func (b *Binary) ExtractPackages(pm *bootstrapper.PackageManifest) error { }) } -func (b *Binary) VerifyFiles(m bootstrapper.Manifest) error { - filesLen := len(m) - filesDone := 0 - - log.Printf("Verifying %d files", filesLen) - - for _, f := range m { - err := util.VerifyFileMD5(filepath.Join(b.Dir, f.Path), f.Checksum) - if err != nil { - return err - } - - filesDone++ - b.Splash.SetProgress(float32(filesDone) / float32(filesLen)) - } - - return nil -} - func (b *Binary) SetupDxvk() error { ver, err := state.DxvkVersion() if err != nil { diff --git a/roblox/bootstrapper/manifest.go b/roblox/bootstrapper/manifest.go deleted file mode 100644 index 3790a0c5..00000000 --- a/roblox/bootstrapper/manifest.go +++ /dev/null @@ -1,65 +0,0 @@ -package bootstrapper - -import ( - "errors" - "fmt" - "log" - "strings" - - "github.com/vinegarhq/vinegar/roblox/version" - "github.com/vinegarhq/vinegar/util" -) - -type File struct { - Path string - Checksum string -} - -type Manifest []File - -var ErrInvalidManifest = errors.New("invalid manifest given") - -func FetchManifest(ver *version.Version) (Manifest, error) { - cdn, err := CDN() - if err != nil { - return Manifest{}, err - } - durl := cdn + channelPath(ver.Channel) + ver.GUID - url := durl + "-rbxManifest.txt" - - log.Printf("Fetching files manifest for %s (%s)", ver.GUID, url) - - smanif, err := util.Body(url) - if err != nil { - return Manifest{}, fmt.Errorf("fetch %s manifest: %w", ver.GUID, err) - } - - // Because the manifest ends with also a newline, it has to be removed. - manif := strings.Split(smanif, "\r\n") - if len(manif) > 0 && manif[len(manif)-1] == "" { - manif = manif[:len(manif)-1] - } - - return ParseFiles(manif) -} - -func ParseFiles(manifest []string) (Manifest, error) { - var m Manifest - - if (len(manifest) % 2) != 0 { - return m, ErrInvalidManifest - } - - for i := 0; i <= len(manifest)-2; i += 2 { - if manifest[i] == "MicrosoftEdgeWebview2Setup.exe" { - continue - } - - m = append(m, File{ - Path: strings.ReplaceAll(manifest[i], `\`, "/"), - Checksum: manifest[i+1], - }) - } - - return m, nil -} diff --git a/roblox/bootstrapper/manifest_test.go b/roblox/bootstrapper/manifest_test.go deleted file mode 100644 index 0f16eb25..00000000 --- a/roblox/bootstrapper/manifest_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package bootstrapper - -import ( - "reflect" - "testing" -) - -func TestParseFiles(t *testing.T) { - manifest := []string{ - "meow\\mew\\nyao", - "026b271a21b03f2e564c036525356db5", - "purr", - "4d9ec7b52a29c80f3ce1f6a65b14b563", - "MicrosoftEdgeWebview2Setup.exe", - "610b1b60dc8729bad759c92f82ee2804", - } - - fs, err := ParseFiles(manifest) - if err != nil { - t.Fatal(err) - } - - fsWant := Manifest{ - File{ - Path: "meow/mew/nyao", - Checksum: "026b271a21b03f2e564c036525356db5", - }, - File{ - Path: "purr", - Checksum: "4d9ec7b52a29c80f3ce1f6a65b14b563", - }, - } - - if !reflect.DeepEqual(fs, fsWant) { - t.Fail() - } -}