diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index 24eba39e..ab60482f 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -270,7 +270,7 @@ func (b *Binary) Install() error { return err } - manifest, err := bootstrapper.FetchManifest(&b.Version) + manifest, err := bootstrapper.FetchPackageManifest(&b.Version) if err != nil { return err } @@ -302,7 +302,7 @@ func (b *Binary) Install() error { return err } - if err := state.SaveManifest(&manifest); err != nil { + if err := state.SavePackageManifest(&manifest); err != nil { return err } @@ -313,11 +313,11 @@ func (b *Binary) Install() error { return state.CleanVersions() } -func (b *Binary) PerformPackages(m *bootstrapper.Manifest, fn func(bootstrapper.Package) error) error { +func (b *Binary) PerformPackages(pm *bootstrapper.PackageManifest, fn func(bootstrapper.Package) error) error { donePkgs := 0 - pkgsLen := len(m.Packages) + pkgsLen := len(pm.Packages) - return m.Packages.Perform(func(pkg bootstrapper.Package) error { + return pm.Packages.Perform(func(pkg bootstrapper.Package) error { err := fn(pkg) if err != nil { return err @@ -330,19 +330,19 @@ func (b *Binary) PerformPackages(m *bootstrapper.Manifest, fn func(bootstrapper. }) } -func (b *Binary) DownloadPackages(m *bootstrapper.Manifest) error { - log.Printf("Downloading %d Packages for %s", len(m.Packages), m.Version.GUID) +func (b *Binary) DownloadPackages(pm *bootstrapper.PackageManifest) error { + log.Printf("Downloading %d Packages for %s", len(pm.Packages), pm.Version.GUID) - return b.PerformPackages(m, func(pkg bootstrapper.Package) error { - return pkg.Fetch(filepath.Join(dirs.Downloads, pkg.Checksum), m.DeployURL) + return b.PerformPackages(pm, func(pkg bootstrapper.Package) error { + return pkg.Fetch(filepath.Join(dirs.Downloads, pkg.Checksum), pm.DeployURL) }) } -func (b *Binary) ExtractPackages(m *bootstrapper.Manifest) error { - log.Printf("Extracting %d Packages for %s", len(m.Packages), m.Version.GUID) +func (b *Binary) ExtractPackages(pm *bootstrapper.PackageManifest) error { + log.Printf("Extracting %d Packages for %s", len(pm.Packages), pm.Version.GUID) pkgDirs := bootstrapper.BinaryDirectories(b.Type) - return b.PerformPackages(m, func(pkg bootstrapper.Package) error { + return b.PerformPackages(pm, func(pkg bootstrapper.Package) error { dest, ok := pkgDirs[pkg.Name] if !ok { diff --git a/internal/state/state.go b/internal/state/state.go index 0a0b4e85..b6f70752 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -62,8 +62,8 @@ func Load() (State, error) { return state, nil } -func SaveManifest(manif *bootstrapper.Manifest) error { - name := manif.Version.Type.BinaryName() +func SavePackageManifest(pm *bootstrapper.PackageManifest) error { + name := pm.Version.Type.BinaryName() log.Printf("Saving Manifest State for %s", name) @@ -73,9 +73,9 @@ func SaveManifest(manif *bootstrapper.Manifest) error { } app := ApplicationState{ - Version: manif.Version.GUID, + Version: pm.Version.GUID, } - for _, pkg := range manif.Packages { + for _, pkg := range pm.Packages { app.Packages = append(app.Packages, pkg.Checksum) } diff --git a/roblox/bootstrapper/manifest.go b/roblox/bootstrapper/pkg_manifest.go similarity index 78% rename from roblox/bootstrapper/manifest.go rename to roblox/bootstrapper/pkg_manifest.go index e4065504..23e3a35a 100644 --- a/roblox/bootstrapper/manifest.go +++ b/roblox/bootstrapper/pkg_manifest.go @@ -12,15 +12,15 @@ import ( "golang.org/x/sync/errgroup" ) -type Manifest struct { +type PackageManifest struct { *version.Version DeployURL string Packages } var ( - ErrInvalidManifest = errors.New("invalid package manifest given") - ErrUnhandledManifestVersion = errors.New("unhandled package manifest version") + ErrInvalidPkgManifest = errors.New("invalid package manifest given") + ErrUnhandledPkgManifestVer = errors.New("unhandled package manifest version") ) type Package struct { @@ -44,10 +44,10 @@ func channelPath(channel string) string { return "/channel/" + channel + "/" } -func FetchManifest(ver *version.Version) (Manifest, error) { +func FetchPackageManifest(ver *version.Version) (PackageManifest, error) { cdn, err := CDN() if err != nil { - return Manifest{}, err + return PackageManifest{}, err } durl := cdn + channelPath(ver.Channel) + ver.GUID url := durl + "-rbxPkgManifest.txt" @@ -56,7 +56,7 @@ func FetchManifest(ver *version.Version) (Manifest, error) { smanif, err := util.Body(url) if err != nil { - return Manifest{}, fmt.Errorf("fetch %s manifest: %w", ver.GUID, err) + return PackageManifest{}, fmt.Errorf("fetch %s package manifest: %w", ver.GUID, err) } // Because the manifest ends with also a newline, it has to be removed. @@ -67,10 +67,10 @@ func FetchManifest(ver *version.Version) (Manifest, error) { pkgs, err := ParsePackages(manif) if err != nil { - return Manifest{}, err + return PackageManifest{}, err } - return Manifest{ + return PackageManifest{ Version: ver, DeployURL: durl, Packages: pkgs, @@ -81,11 +81,11 @@ func ParsePackages(manifest []string) (Packages, error) { pkgs := make(Packages, 0) if (len(manifest)-1)%4 != 0 { - return pkgs, ErrInvalidManifest + return pkgs, ErrInvalidPkgManifest } if manifest[0] != "v0" { - return pkgs, fmt.Errorf("%w: %s", ErrUnhandledManifestVersion, manifest[0]) + return pkgs, fmt.Errorf("%w: %s", ErrUnhandledPkgManifestVer, manifest[0]) } for i := 1; i <= len(manifest)-4; i += 4 { diff --git a/roblox/bootstrapper/manifest_test.go b/roblox/bootstrapper/pkg_manifest_test.go similarity index 90% rename from roblox/bootstrapper/manifest_test.go rename to roblox/bootstrapper/pkg_manifest_test.go index ac3da6ae..2d81fb67 100644 --- a/roblox/bootstrapper/manifest_test.go +++ b/roblox/bootstrapper/pkg_manifest_test.go @@ -49,7 +49,7 @@ func TestParsePackages(t *testing.T) { } } -func TestInvalidPackageManifest(t *testing.T) { +func TestInvalidPackagePackageManifest(t *testing.T) { manifest := []string{ "v0", "foo.zip", @@ -58,7 +58,7 @@ func TestInvalidPackageManifest(t *testing.T) { } _, err := ParsePackages(manifest) - if !errors.Is(err, ErrInvalidManifest) { + if !errors.Is(err, ErrInvalidPkgManifest) { t.Fail() } @@ -70,7 +70,7 @@ func TestInvalidPackageManifest(t *testing.T) { } } -func TestUnhandledPackageManifest(t *testing.T) { +func TestUnhandledPackagePackageManifest(t *testing.T) { manifest := []string{ "v1", "foo.zip", @@ -80,7 +80,7 @@ func TestUnhandledPackageManifest(t *testing.T) { } _, err := ParsePackages(manifest) - if !errors.Is(err, ErrUnhandledManifestVersion) { + if !errors.Is(err, ErrUnhandledPkgManifestVer) { t.Fail() } }