diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index 1f672919..a1b8d00f 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -111,7 +111,7 @@ func (b *Binary) Main(args ...string) error { logFile, err := LogFile(b.Type.String()) if err != nil { - return err + return fmt.Errorf("failed to init log file: %w", err) } defer logFile.Close() @@ -170,7 +170,7 @@ func (b *Binary) Main(args ...string) error { } if err != nil { - return err + return fmt.Errorf("failed to init %s prefix: %w", b.Type, err) } } @@ -223,7 +223,7 @@ func (b *Binary) Run(args ...string) error { cmd, err := b.Command(args...) if err != nil { - return err + return fmt.Errorf("%s command: %w", b.Type, err) } // Act as the signal holder, as roblox/wine will not do anything with the INT signal. @@ -272,10 +272,9 @@ func (b *Binary) Run(args ...string) error { } } - // Blocks and tails file forever until roblox is dead - if err := b.Tail(lf); err != nil { - log.Println(err) - } + // Blocks and tails file forever until roblox is dead, unless + // if finding the log file had failed. + b.Tail(lf) }() if err := cmd.Run(); err != nil { @@ -324,10 +323,11 @@ func RobloxLogFile(pfx *wine.Prefix) (string, error) { } } -func (b *Binary) Tail(name string) error { +func (b *Binary) Tail(name string) { t, err := tail.TailFile(name, tail.Config{Follow: true}) if err != nil { - return err + log.Printf("WARNING: failed to tail roblox log file: %s", err) + return } for line := range t.Lines { @@ -339,8 +339,6 @@ func (b *Binary) Tail(name string) error { } } } - - return nil } func (b *Binary) Command(args ...string) (*exec.Cmd, error) { diff --git a/cmd/vinegar/binary_setup.go b/cmd/vinegar/binary_setup.go index 8fed3f94..6281147b 100644 --- a/cmd/vinegar/binary_setup.go +++ b/cmd/vinegar/binary_setup.go @@ -27,7 +27,7 @@ func (b *Binary) FetchDeployment() error { d, err := boot.FetchDeployment(b.Type, b.Config.Channel) if err != nil { - return err + return fmt.Errorf("fetch %s %s deployment: %w", b.Type, b.Config.Channel, err) } b.Deploy = &d @@ -46,7 +46,7 @@ func (b *Binary) Setup() error { log.Printf("Installing %s (%s -> %s)", b.Name, b.State.Version, b.Deploy.GUID) if err := b.Install(); err != nil { - return err + return fmt.Errorf("install %s: %w", b.Deploy.GUID, err) } } else { log.Printf("%s is up to date (%s)", b.Name, b.Deploy.GUID) @@ -56,19 +56,23 @@ func (b *Binary) Setup() error { log.Println("Using Renderer:", b.Config.Renderer) if err := b.Config.FFlags.Apply(b.Dir); err != nil { - return err + return fmt.Errorf("apply fflags: %w", err) } if err := dirs.OverlayDir(b.Dir); err != nil { - return err + return fmt.Errorf("overlay dir: %w", err) } if err := b.SetupDxvk(); err != nil { - return err + return fmt.Errorf("setup dxvk: %w", err) } b.Splash.SetProgress(1.0) - return b.GlobalState.Save() + if err := b.GlobalState.Save(); err != nil { + return fmt.Errorf("save state: %w", err) + } + + return nil } func (b *Binary) Install() error { @@ -80,11 +84,7 @@ func (b *Binary) Install() error { pm, err := boot.FetchPackageManifest(b.Deploy) if err != nil { - return err - } - - if err := dirs.Mkdirs(dirs.Downloads); err != nil { - return err + return fmt.Errorf("fetch %s package manifest: %w", b.Deploy.GUID, err) } // Prioritize smaller files first, to have less pressure @@ -97,12 +97,12 @@ func (b *Binary) Install() error { b.Splash.SetMessage("Downloading " + b.Alias) if err := b.DownloadPackages(&pm); err != nil { - return err + return fmt.Errorf("download %s packages: %w", b.Deploy.GUID, err) } b.Splash.SetMessage("Extracting " + b.Alias) if err := b.ExtractPackages(&pm); err != nil { - return err + return fmt.Errorf("extract %s packages: %w", b.Deploy.GUID, err) } if b.Type == roblox.Studio { @@ -115,16 +115,20 @@ func (b *Binary) Install() error { } if err := boot.WriteAppSettings(b.Dir); err != nil { - return err + return fmt.Errorf("appsettings: %w", err) } b.State.Add(&pm) if err := b.GlobalState.CleanPackages(); err != nil { - return err + return fmt.Errorf("clean packages: %w", err) + } + + if err := b.GlobalState.CleanVersions(); err != nil { + return fmt.Errorf("clean versions: %w", err) } - return b.GlobalState.CleanVersions() + return nil } func (b *Binary) PerformPackages(pm *boot.PackageManifest, fn func(boot.Package) error) error { @@ -179,7 +183,7 @@ func (b *Binary) SetupDxvk() error { (!b.GlobalConfig.Player.Dxvk && !b.GlobalConfig.Studio.Dxvk) { b.Splash.SetMessage("Uninstalling DXVK") if err := dxvk.Remove(b.Prefix); err != nil { - return err + return fmt.Errorf("remove dxvk: %w", err) } b.State.DxvkVersion = ""